MPMoviePlayerViewController gets dissmiss when app goes background - iphone

If I press on Home Button, or switch to another app, while MPMoviePlayerViewController on screen, and open app again it shows UIViewController who sent
moviePlayerViewControllerAnimated:.
How can I just pause my video like youtube app?

There is an option in the project's plist.The option is "Application does not run in background",May this is set to YES.This may be one reason

Related

iphone home button event

I am developing a iPhone application and would need to track the home button pressed event by user while the app is in background mode.I have go through the apple documentation/apis but could not find out any to track.
It would be great if anyone can help me on this to track the iPhone home button pressed event.
Your application can't catch any events while in the background. There are some special cases which allows your app to do some tasks in the background, but even them wouldn't allow you to listen to Home button interaction.
You cann't track the home button pressed or not but as your situation is to see if application went in background or not. for this there is a method applicationDidEnterBackground:(UIApplication *)application. This method is called as the application enters into background.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"Application Entered Into Background.");
}

iOS view offset after youTube video execution

I am calling a youtube channel on a UIWebView. When user selects a video, device launches its video player as normal. However, when video ends or user finishes it returning to view, an offset is applied to whole app!! All views have an offset on top but this only happens on iPad and iPad simulator with compatibility mode, on iPhone and iPhone simulator not! How to solve it? Thank you.
Problem is that status bar dissapears after video execution.
[[UIApplication sharedApplication] setStatusBarHidden:NO]; problem is beeing solved when an event is fired using NSNotificationCenter

iPhone - Need to replay background sound when it comes to foreground from background

My application plays a background music when it launches. It stops when I quit the application. But not playing the music again when I open my application. The application has 2 views and I want to play background sound on only main view. So when the app launches it should play the sound until user quit the app or when the user goes to the second view in the app. The sound should be played again only when the user returns to the main view. Currently, I am calling the sub function which plays the sound in 'viewDidLoad' function. please help.
Thanks
Try using this method in your AppDelegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
DidBecomeActive Apple Documentation

Issue with MPMoviePlayerController playing an audio after a YouTube Video is opened in a Webview

In one View Controller ViewController1, I have tried to open a You tube video embedded in a UIWebview. It opens in the Movie Player window and then I use the "Done" button to come out of the movie player window. Again in another view controller ViewController2 in the same application, I open a MPMoviePlayerController(MPMoviePlayerController *audioplayer) to play an audio file using streaming. However, it remains in the paused state on opening the player. Even when i call the method [audioplayer play], the application automatically sets back the playback state to paused (i rechecked and it is not done through my code).
But if i reopen the application and in view controller ViewController2 i play the audio alone, then MPMoviePlayerController *audioplayer plays successfully.
Any idea what i might be doing wrong ?
This issue was found to be specific only to ios4.0.
This issue doesnt occur in ios4.1 and above.

MPMoviePlayerViewController Not Rotating until app restart

K here is an interesting problem
We have an app that is presenting with unusual behavior
If you install that app (from either test flight or via xcode debug) onto a "clean" device (where the app has not existed before or has been previously delete) when the app plays a mp4 from the web or from local memory. The MPMoviePlayerViewController used to play the app will not rotate.
However if you force quit the app and start it again, everything rotates correctly. Even if you quit and return without closing the background thread the video will not rotate.
Here is the simple code
mediaController = [[MPMoviePlayerViewController alloc] initWithContentURL: [NSURL fileURLWithPath: videoPath]];
[self presentMoviePlayerViewControllerAnimated: mediaController];
[mediaController release];
Any Ideas?
It might be that one of the root view for another one of the tabs is stopping the root view containing your player from rotating. The UITabBarController asks all its children view controllers (one for each tab) whether it should allow rotation and will only allow one to rotate to a given orientation if all of them allow it. This is done so as to avoid the orientation switching violently from one to another when the user switches tabs. Try putting a breakpoint in the shouldAllowAutoRotation for all of the UITabBarController's children and see if they get called.
I discovered the issue with this. the UIWindow can only have one view. If another is added, 2nd views will not receive the notification. I had an action that was triggering on the first load that was doing this causing the views to not rotate.