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

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.

Related

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

MPMoviePlayerViewController gets dissmiss when app goes background

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

Cannot get MPMoviePlayerController to return to my TableView

I have a table view that has a list videos. When I click on one it uses MPMoviePlayerController to play the corresponding video. I cannot figure out how to have the player return to the list-view when the video finishes or I click on the done button.
I read the documentation and they said there was a
MPMoviePlayerPlaybackDidFinishNotification.
I figure I could have code that would go off when the notification was sent to go back to my list-view, but:
I do not understand notifications. Are they like using a delegate for a call back?
After I detected the notification, how would I tell the player to go away?
If you use the MPMoviePlayerViewController then the approach is something like:
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentUrl:url];
[myViewController presentMoviePlayerViewControllerAnimated:player];
You don't need to worry about the notification then. Once the user clicks done the movie player will go away.

MPMoviePlayerController vs. MPMoviePlayerViewController

I'm new to iPhone development. Just wondering what the difference is between the MPMoviePlayerController and the MPMoviePlayerViewController. Also, more generally, what is the difference between a controller and a view controller? I know that you use a controller to construct a view (as with MPMoviePlayerController.view), so what does a ViewController create?
The MPMoviePlayerController is just a movie player, it provides a way for you to play movies on the iPhone, a MPMoviePlayerViewController is an actual view controller subclass that takes care of presentation of the MPMoviePlayerController...as documentation at apple puts it
"An MPMoviePlayerController instance, or movie player, manages the playback of a movie from a file or a network stream. Playback occurs either in full-screen mode or in a custom view that is vended by the movie player. You can incorporate the view into your own view hierarchies or use an MPMoviePlayerViewController object to manage the presentation for you."
There is no relation between a viewControler and a controller, this class just happens to be named MPMoviePlayerController because it gives you control over the movie player. Actually before (4.0 i think) there was no view controller and just the movie player, later apple decided to incorporate the movie player view controller too.
Zaius,
In the simplest terms, MPMoviePlayerViewController displays the movie/video using the MPMoviePlayerController.
hence, MPMoviePlayerController is a property in MPMoviePlayerViewController that you can access.
MPMoviePlayerViewController.moviePlayer is the property that you'd use to access MPMoviePlayerController properties.
Hope anyone hitting this thread will find this useful!
Example:
MyMoviePlayerViewController * moviePlayerVC = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
moviePlayerVC.moviePlayer.allowsAirPlay = YES;

Stopping video in viewWillAppear:(bool)animated method

In my viewWillAppear:(bool)animated method I want to stop video playing. How can I do this? I am new I don't know much.
I am playing a video on this screen. I have a tab which shows table view. When I click on the tab the table view is shown but video is playing in background: we can hear the music.
If you are using MPMoviePlayerController, call -pause on that object.