开发者

MPMoviePlayerController Audio show "Done" Button

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".


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];


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜