我们想要创建一个简短的3-4秒的电影重复,就像他们在苹果贴士应用程序,在那里你可以看到一些使用iPhone在电影中重复多次的例子。
我想他们不是在使用动画(并为它创建许多图像),而是使用某种类型的电影播放器--问题是,什么是最好的播放器--所以它看起来就像一个gif,没有的--播放器工具栏(play/stop/等等)。
谢谢。
发布于 2015-08-25 12:06:08
使用AVPlayer连续播放视频,看起来就像一个gif在连续播放。
-(void)startPlaybackForItemWithURL{
// First create an AVPlayerItem
// Subscribe to the AVPlayerItem's DidPlayToEndTime notification.
NSString*thePath=[[NSBundle mainBundle] pathForResource:@"vegas" ofType:@"mov"];
NSURL*theurl=[NSURL fileURLWithPath:thePath];
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:theurl];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:playerItem];
player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
AVPlayerLayer *layer = [AVPlayerLayer layer];
[layer setPlayer:player];
[layer setFrame:CGRectMake(0, 0, 443, 239)];
[layer setBackgroundColor:[UIColor clearColor].CGColor];
[layer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[viewVideo.layer addSublayer:layer];
[player play];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:player];
}https://stackoverflow.com/questions/32203413
复制相似问题