使用MPMoviePlayerController播放多个视频 [英] Playing multiple Videos using MPMoviePlayerController

查看:41
本文介绍了使用MPMoviePlayerController播放多个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有多个视频,我希望当用户按下MPMoviePlayerController中的下一个或上一个按钮时,MPMoviePlayerController应该是特定的歌曲,但是问题是MPMoviePlayerController仅具有SeekingForward或for的通知落后.如何使用MPMoviePlayerController中的FastForward和BackWard按钮实现上一个和下一个功能.

In my app i have multiple Videos and i want that when the user press the next or previous button in the MPMoviePlayerController, the MPMoviePlayerController should the particular song.But the problem is that the MPMoviePlayerController has only the notification for the SeekingForward or for Backward. How to implement the previous and next functionality using the FastForward and the BackWard Button inside the MPMoviePlayerController.

推荐答案

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.

这篇关于使用MPMoviePlayerController播放多个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆