MPMoviePlayerController code plays video on iPhone (running 4.3) but not on iPodTouch (running 4.2)
I'm working on a tab bar application that has three views - One of the views is a table view whose rows are tied to a video on our server.
I am using the MPMoviePlayerController class to try and serve these up. My issue is the videos launch and playback just fine on my iPhone, but on my iPodTouch all I get is a black screen - No controls, no video.
Here is the code I am using to launch the videos in question:
NSURL * url = [NSURL URLWithString:@"http://209.85.225.147/AbCoaster.mp4"];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayerController.view];
开发者_StackOverflow moviePlayerController.fullscreen = YES;
[moviePlayerController play];
Any ideas why this works fine on one device but not on the other?
Thanks in advance.
After a quick glance that looks like it should work (and does in 4.3). I did a quick Google search for MPMoviePlayerController iOS 4.2 and found this link that is the change log for iOS 4.1 to 4.2.
http://developer.apple.com/library/ios/#releasenotes/General/iOS42APIDiffs/index.html
If you scroll down and look at the changes to MPMoviePlayerController you will see that is 4.2 Apple removed [MPMoviePlayerController play] method. The must have added the functionality back in to the library in 4.3. I would try setting [MPMoviePlayerController shouldAutoPlay] to true. That property will tell the video to start as soon as the buffer has enough video buffered to ensure uninterrupted playback.
If that doesn't work then you might not be able to tell the video to auto play.
Good Luck!
精彩评论