我正在使用AVPlayerViewController
以全屏模式显示我的视频。在我的BaseController
中,我已经实施了AVPlayerItem
和AVPlayer
。我已经添加了self.playerItem.actionAtItemEnd = AVPlayerActionAtItemEnd.None
,并且正在为AVPlayerItemDidPlayToEndTimeNotification
添加通知。问题是,那是在BaseController
而不是AVPlayerViewController
.阅读Apple文档,子类化AVPlayerViewController
有严格的NO。
重要 不要子类化 AVPlayerViewController。重写此类的方法不受支持,并导致未定义的行为。
检测已完成AVPlayerViewController
AVPlayerItem
以便我可以设置seekToTime(kCMTimeZero)
的最佳方法是什么?我可以使用AVPlayer
将其添加为子视图并循环播放视频,但我希望能够从AVPlayerViewController
循环播放视频
试试这个人:
- (void)playerItemDidReachEnd:(NSNotification *)notification {
AVPlayerItem *p = [notification object];
[p seekToTime:kCMTimeZero];}