欢迎光临
我们一直在努力

AKVideoImageView

建站超值云服务器,限时71元/月

AKVideoImageView

项目介绍:

AKVideoImageView

This class was created because I wasn’t satisfied with standard Apple AVPlayer during creating a video background for one of my apps. AVPlayer doesn’t let the phone to go to sleep mode. Also, you can’t insensibly start a video from the first frame when app enters background. This class solves these problems, and in the end, you have a perfect solution for making gorgeous video backgrounds for your apps.

AKVideoImageView Example

Features

  • Ability to dynamically switch videos

  • Auto set the first frame of video to have seamless transition when app returns from background

  • Minimal memory footprint

  • Good performance

  • Ability to use mp4 files as video source

Installation

Manually

Just add AKVideoImageView.h and AKVideoImageView.m files to your project.

CocoaPods

Add the following line to your Podfile.

pod "AKVideoImageView", "~> 1.0"

Then run pod install.

Usage

Compressing your video file

Before starting using this class, you need to properly compress video.
Here is an example of libx264 compression options on OS X system using ffmpeg utility:

ffmpeg -i input.mov -vcodec libx264 -level 3.1 -pix_fmt yuv420p -threads 1 -preset placebo -crf 19 -tune film -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709:fullrange=off output.mp4

Basic Setup

In your view controller:

#import "AKVideoImageView.h"

NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"videoName" withExtension:@"mp4"];
AKVideoImageView *videoBG = [[AKVideoImageView alloc] initWithFrame:self.view.bounds
                                                           videoURL:videoURL];
[self.view addSubview:videoBG];
[self.view sendSubviewToBack:videoBG];

Dynamically changing video

NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"anotherVideoName" withExtension:@"mp4"];
self.videoBG.videoURL = videoURL;

code4app

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » AKVideoImageView
分享到: 更多 (0)