MPMoviePlayerController 音频节目“完成”按钮

发布于 2024-10-17 18:54:24 字数 983 浏览 1 评论 0原文

我使用 MPMoviePlayerController 来播放音频流。 我的代码遵循以下示例:

http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk .html

一切正常,但在播放流时没有“完成” 按钮关闭播放器。

我首先使用普通的 .mp3 文件对其进行了测试。与文件唯一 我发现的可能性是跳到最后, 因此播放器会收到 MPMoviePlayerPlaybackDidFinishNotification 通知 (但这不会在无休止的流中起作用,因为没有时间表 跳到最后)。

我尝试了各种样式,例如 [mp setControlStyle:MPMovieControlStyleFullscreen]; 但没有成功。

在文档中 MPMoviePlayerController 类代表:

此类播放任何电影或音频 iOS 支持的文件。这包括 流式内容和固定长度 文件

是否有可能在播放某些音频时显示该按钮 内容,或者还有其他解决方案吗?

我试图向您展示屏幕截图,但“新用户最多只能发布两个超链接”。

I use the MPMoviePlayerController to Play an Audio Stream.
My code follows the example at:

http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html

Everything works fine, but while the stream is playing there is no "done"
button to close the Player.

I tested it first with a normal .mp3 file. With the file the only
possibility I found is to skip to the end,
so the player gets the MPMoviePlayerPlaybackDidFinishNotification
notification
(but this won't work on an endless stream, since there is no timeline to
skip to the end).

I tried various styles like [mp setControlStyle:MPMovieControlStyleFullscreen]; with no succes.

In the documentation at
MPMoviePlayerController Class stands:

This class plays any movie or audio
file supported in iOS. This includes
both streamed content and fixed-length
files

Is there a possibility to display that button while playing some audio
content, or has anyone another solution?

I tried to show you an screenshot but "new users can only post a maximum of two hyperlinks".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-10-24 18:54:24

我自己找到了解决方案。

使用 MPMoviePlayerViewController 类而不是 MPMoviePlayerController 解决了这个问题:

NSString *path = @"http://yourstreamingurl.com/stream.m3u";

MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  
[self presentModalViewController:mpviewController animated:YES];
[[mpviewController moviePlayer] play];

i found a solution by my self.

Using the MPMoviePlayerViewController class, instead of MPMoviePlayerController solved the problem:

NSString *path = @"http://yourstreamingurl.com/stream.m3u";

MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  
[self presentModalViewController:mpviewController animated:YES];
[[mpviewController moviePlayer] play];
贵在坚持 2024-10-24 18:54:24

对于本地播放文件,请删除

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  

否则它将返回

Terminating app due to uncaught exception NSInvalidArgumentException reason An AVPlayerItem cannot be associated with more than one instance of AVPlayer

For playing file locally, remove

mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  

Other wise it will return

Terminating app due to uncaught exception NSInvalidArgumentException reason An AVPlayerItem cannot be associated with more than one instance of AVPlayer
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文