Can't stop movie playback immediately - iphone

When you launch a video and IMMEDIATELY press "Done" the MPMoviePlayerController will exit, however the video still plays in the background (you can hear the audio). It works fine if you allow the video to begin playing before you hit the "Done" button.
Does anybody know a workaround for this?

Try calling stop on your MPMoviePlayerController instance when the view controller that spawned the movie receives its viewDidAppear: (or viewWillAppear:) methods

While, so far, I've also found MPMoviePlayerController somewhat erratic, I imagine just releasing the object (after listening to a MPMoviePlayerPlaybackDidFinishNotification) would help.

Update: This seems to be a known 3.0 bug. I was unable to find a workaround
http://www.iphonedevsdk.com/forum/iphone-sdk-development-advanced-discussion/15768-mpmovieplayer-video-via-url-glitch.html

Related

MPMoviePlayerController - handle phone call

I'm using MPMoviePlayerController to play a video.
When a call comes, i want to pause and when he completes, i want to continue the video.
I couldn't find relevant solution in my search.
Is this something possible?
Its possible to handle the interruptions using AVAudioSessionDelegate "beginInterruption" and "endInterruption". But when I am setting the session to play back, my movie player sound is not heard at all.
Does any one know the solution?
There is a callEventHandler in Core Telephony framework. I hope, You could find what you want here.
We've to set the session active after endInterruption.

Continuous background audio with MPMoviePlayerController?

I am using MPMoviePlayerController to play streaming audio. I'm trying to get background audio working correctly. Right now, audio continues to play when you exit the app - the lock-screen and multi-tasking bar controls even work.
When a song finishes, the app is supposed to advance to the next track and play it. It works when the app is open but not when it is in the background (a song finishes but does not advance to the next track). If a song finishes and you re-open the app, however, the next song will start up immediately.
I am currently using NSNotificationCenter to keep track of when tracks end to advance to the next track (in my app delegate). Again, it works like a charm when the app is open. Is there a better way to do this to keep audio playing after a song is done?
I had this issue lately. Hope the answer helps other people.
If you have a playlist for example and want to play the next song while in background mode or lock mode add this line of code on your viewDidLoad:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
This makes the app supports remote control events.

setIdleTimerDisabled and MPMusicPlayer Issue

Ok I want to disable the idletimer in my app. I put the code below in appdelegate in the applicationDidFinishLaunching method, and it works fine (the device remains unlocked)
[application setIdleTimerDisabled:YES];
Though, when I play a music through MPMusicPlayer methods, the idletimer seems to be enabled back again... and soon the device goes into dimmed mode and soon after, "locked" mode.
I tried to find in google for other methods, but ultimately there are NONE that are effective. I also tried putting the above code in another function and calling that function every seconds using NSTimer when the music is playing, but to no avail. It just won't work.
How can I solve this issue?
Ugh. I hate answering my own questions. But here you go, the answer is here:
How to stop MPMusicPlayerController from enabling screen locking
See the reply from henning. Works like a charm!

iPhone how to stop MPMoviePlayerController is closing at the end?

In my iPhone app, I'm using MPMoviePlayerController to play a movie. I'm hiding all the controls that are by default visible on the movie player. But I placed a "Replay" button over the player control.
At the end of movie, the player is being removed. But I want to stop at the last frame, so that when I click "Replay" button, it will start from beginning. I wrote the functionality for replay and its working good. When ever the movie is playing and on click of "Replay", its restarting the video from starting.
The problem I'm facing is that, at the end of movie its becoming white screen and pressing "Replay" button is not restarting the movie. How to handle this situation?
Its not necessary to create new instance. I found out the solution. Don't just release the instance of player. When replay button is clicked (either in middle of video or after completion), just pause it, move the location to beginning and play it. That's it.. no retain, no release nothing.... Its upto the programmer/developer when to release the player and remove it from the view.
I never used MPMoviePlayerController but pherhaps it's instance is released when the movie has ended. In this case incrementing the retaincounter and manually releasing it would solve the problem.

How to keep MPMoviePlayerController open after movie ended?

If I use MPMoviePlayerController to play video in my iPhone app, it opens, loads the movie, plays it and then closes. Is it possible to force it to stay open after the movie finishes, so that user can replay it using its controls, instead of using controls in parent view? Also, is it possible to start MPMoviePlayerController in the paused mode?
thanks for any advice.
None of that is possible using the available API in the Pre-3.2 OS. One thing you could do is take a scerenshot of the last frame and stick that behind the movie so when it's done playing, it looks like it's still there, then just stick a button on it to replay. you could make an interface that looks/behaves similar to the standard movie player interface just for the play button if you need to.
For anyone stumbling over this now... There is a way to do this. Check out this question :)