重复 3 秒影片以获取帮助视图?

问题描述 投票:0回答:1

我们希望制作一个 3-4 秒的重复短片,就像在 Apple Tips 应用程序 中所做的那样,您可以在其中看到一些在重复多次的电影中使用 iPhone 的示例。

我猜他们没有使用动画(并为其创建许多图像),而是使用某种电影播放器。我的问题是,最好使用的播放器是什么 - 所以它看起来像 GIF,没有播放器工具栏(播放/停止/等)。

ios objective-c
1个回答
1
投票

使用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];
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.