首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重复3秒的电影以获得帮助视图?

重复3秒的电影以获得帮助视图?
EN

Stack Overflow用户
提问于 2015-08-25 11:58:10
回答 1查看 33关注 0票数 1

我们想要创建一个简短的3-4秒的电影重复,就像他们在苹果贴士应用程序,在那里你可以看到一些使用iPhone在电影中重复多次的例子。

我想他们不是在使用动画(并为它创建许多图像),而是使用某种类型的电影播放器--问题是,什么是最好的播放器--所以它看起来就像一个gif,没有的--播放器工具栏(play/stop/等等)。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-25 12:06:08

使用AVPlayer连续播放视频,看起来就像一个gif在连续播放。

代码语言:javascript
复制
-(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];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32203413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档