I am using the following code to try and show a YouTube movie in my app. The Video player appears, shows the controls for a second, and then the movie player retracts. The app does not crash. Any ideas how to make this work?
MPMoviePlayerViewController *mpViewController =
[[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=VKsVSBhSwJg"]];
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[self presentMoviePlayerViewControllerAnimated:mpViewController];
[mpViewController release];
I don’t remember where I read it, but I do remember that YouTube doesn’t let you play videos in an
MPMoviePlayerViewController— you have to point the user to the YouTube app or use aUIWebView(as they detail here). I suppose you could do what Felz suggests but it would be against YouTube’s policies.Hope this helps!