//利用AVFouncation实现
NSURL *url=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1" ofType:@".mp4" ]];
//带有循环播放的player
//获取播放的对象
item=[AVPlayerItem playerItemWithURL:url];
//创建一个player
quePlayer =[[AVQueuePlayer alloc]init];
//循环播放item
playerLooper=[AVPlayerLooper playerLooperWithPlayer:quePlayer templateItem:item];
playerLayer =[AVPlayerLayer playerLayerWithPlayer:quePlayer];
playerLayer.frame=self.view.frame;
[self.view.layer insertSublayer:playerLayer atIndex:0];
[quePlayer play];
github例子
本文介绍如何使用AVFoundation框架实现MP4视频文件的循环播放功能。通过创建AVPlayerItem和AVQueuePlayer,并利用AVPlayerLooper设置循环播放,最终将播放层添加到视图中进行显示。
1万+

被折叠的 条评论
为什么被折叠?



