且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用MPMoviePlayerController播放多个视频

更新时间:2023-09-22 09:45:10

Apple引入了名为 AVQueuePlayer 的新类,您可以在该类值得使用的时候播放许多视频,然后再使用不支持的MPMoviePlayerController播放多部电影.

Apple introduced new class Called AVQueuePlayer using this you can play many videos at a time this class is worth using then MPMoviePlayerController which not support playing multiple movies.

AVQueuePlayer 从IOS 4.1起可用,并且在其上方是AVPlayer子类.如果您熟悉AVPlayer

AVQueuePlayer is avalible from IOS 4.1 and above it is subclass AVPlayer. If u familiar with AVPlayer

您可以通过通话更改当前正在播放的电影

You can change current running movie with call

[self.queuePlayer advanceToNextItem];

您可以查看示例代码您可以从此处

另一种想法(最坏的情况).

通过以下方式注册通知

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

并将此函数添加到您的对象中

And add this function to your object:

-(void)moviePlayerPlaybackStateChanged:(NSNotification *)notification {
    MPMoviePlayerController *moviePlayer = notification.object;
    MPMoviePlaybackState playbackState = moviePlayer.playbackState;
    // ...
}

我怀疑您会发现您正在获取这些按钮的MPMoviePlaybackStateSeekingForward和... SeekingBackward更新.

I suspect you'll find that you're getting MPMoviePlaybackStateSeekingForward and ...SeekingBackward updates for those buttons.

查看详细信息并为MPMoviePlayerController设置相应的URL,或使用相应的URL再次初始化MPMoviePlayerController.

And set the corresponding URL's for the MPMoviePlayerController or initialize again the MPMoviePlayerController with the corresponding URL's.