iOS-AVPlayer循环播放
AVPlayerItem*videoItem = [[AVPlayerItemalloc] initWithURL:pathUrl];
AVPlayer*player = [AVPlayerplayerWithPlayerItem:videoItem];
player.volume =0;
AVPlayerLayer*playerLayer = [AVPlayerLayerplayerLayerWithPlayer:player];
playerLayer.backgroundColor = [UIColorwhiteColor].CGColor;
playerLayer.videoGravity =AVLayerVideoGravityResizeAspectFill;
playerLayer.frame =self.view.bounds;
[self.view.layer insertSublayer:playerLayer atIndex:0];
[player play];
self.player = player;
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(moviePlayDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotificationobject:self.player.currentItem];
- (void)dealloc {
[[NSNotificationCenterdefaultCenter] removeObserver:self];
}
// 视频循环播放
- (void)moviePlayDidEnd:(NSNotification*)notification{
AVPlayerItem*item = [notification object];
[item seekToTime:kCMTimeZero];
[self.player play];
}