我用这个视频来播放没有secondVideoItem的jerk.But如何在loop..That中播放视频后,我想把这个视频添加到10-15次。只有secondVideoItem而不是firstVideoItem.
NSString *secondVideoPath = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
NSString *firstVideoPath = [[NSBundle mainBundle] pathForResource:@"video2" ofType:@"mp4"];
AVPlayerItem *firstVideoItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:firstVideoPath]];
AVPlayerItem *secondVideoItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:secondVideoPath]];
AVQueuePlayer* queuePlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:firstVideoItem, secondVideoItem,nil]];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:queuePlayer];
avPlayer.actionAtItemEnd = AVPlayerItemStatusReadyToPlay;
layer.frame = CGRectMake(0, 0, 1024, 768);
[self.view.layer addSublayer:layer];
[queuePlayer play];谢谢你
发布于 2013-03-12 10:24:16
在播放完第二项后,这将调用一个通知并将视频倒带,以便它将再次播放.
queuePlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(itemPlayEnded:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[queuePlayer currentItem]];
- (void)itemPlayEnded:(NSNotification *)notification
{
k++;
if(k<10-15 times)
{
AVPlayerItem *p = [notification object];
[p seekToTime:kCMTimeZero];
}
}https://stackoverflow.com/questions/15358274
复制相似问题