MPMoviePlayerController Done Audio Show

I am using MPMoviePlayerController to play an audio stream. My code follows an example:

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" to close the player.

At first I tested it with a normal .mp3 file. Only with the file the opportunity that I found is to skip to the end, so the player receives an MPMoviePlayerPlaybackDidFinishNotification notification (but this will not work on an endless stream, since there is no time to skip to the end).

I tried various styles like [mp setControlStyle:MPMovieControlStyleFullscreen]; without any successful action.

In the MPMoviePlayerController Class documentation:

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

Is it possible to display this button while playing some sound of content or has any other solution?

I tried to show you a screenshot, but "new users can publish a maximum of two hyperlinks."

+4
source share
2 answers

I found a solution myself.

Using the MPMoviePlayerViewController class instead of MPMoviePlayerController , the problem is resolved:

 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]; 
+13
source

To play the file locally, delete

 mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; 

In another case, he will return

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

Source: https://habr.com/ru/post/1340198/


All Articles