我知道AVPlayerItem(AVPlayer的一個子類)能夠訂閱AVPlayerItemDidPlayToEndTimeNotification
註冊AVPlayer事件 - 怎麼知道AVPlayer播放完畢的電影
AVPlayer不具備這樣的能力,我需要使用AVPlayer除非沒有辦法解決這個問題,並知道播放(我的視頻)是否完成。
如何在AVPlayer中執行此操作?我閱讀了這些課程的一些文檔,我沒有看到直接的答案。
-(void)setupVideoView{
_videoPlayer = [AVPlayer playerWithURL:urlObjectHere];
AVPlayerLayer *layer = [AVPlayerLayer layer];
[layer setPlayer:_videoPlayer];
[layer setFrame:_videoView.bounds];
[_videoView.layer addSublayer:layer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itemDidFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:_videoPlayer];
}
-(void)itemDidFinishPlaying:(NSNotification *) notification {
// does not get called
DLog(@"");
}
我是否應該取消它並使用MPMoviePlayer來代替? – stackOverFlew