AVPlayer 重複播放
2015-11-30 本文已影响571人
ShinrenPan
- 步驟1: 設置 actionAtItemEnd.
- 步驟2: 監聽 AVPlayerItemDidPlayToEndTimeNotification Notification.
_player = [AVPlayer playerWithPlayerItem:item];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone; // set this
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(__playerItemDidPlayToEndTimeNotification:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:nil];
- (void)__playerItemDidPlayToEndTimeNotification:(NSNotification *)sender
{
[_player seekToTime:kCMTimeZero]; // seek to zero
}