I have created my iPhone app in Xcode 4 with base SDK 4.3
In my iPhone app I have used MPMovieplayercontroller and using that I am playing Video
It is playing my video file in my iPod Touch with IOS 4.3 but if I install same project in my iPad with iOS 5, it is showing black screen only but not playing video.
what could be wrong?
Here is the code
in .h file
MPMoviePlayerController *moviePlayer;
in .m file
-(void)playVideo{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"testbild1" ofType:@"m4v"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
UIView *testview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[testview addSubview:moviePlayer.view];
[self.view addSubview:testview];
}
- (void)moviePlaybackComplete:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
}
It doesn’t look like you’re setting autoplay
So like:
You should also be probably calling
prepareToPlayand play from theMPMediaPlaybackprotocol thatMPMoviePlayerControllerimplementsOld Post (should have been a comment):
What version iOS? iOs 5.1 beta just came out and alters how MPMoviePlayerController works.
You can get details on Apple’s iOS beta site but I can’t print them here YAY EULA.
EDIT
Now that the OS is public, here’s the relevant documentation (registration — you might have to pay the $100 as well, I forget…)
prepareToPlayon that page — no deep linking)