Here is my code
-(IBAction)playvideo:(id)sender
{
NSLog(@"Get in");
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video3" ofType:@"MOV"];
MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
NSLog(@"movie path %@",moviePath);
NSLog(@"movie %@",movie);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieViewFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:movie];
movie.controlStyle = MPMovieControlStyleDefault;
movie.shouldAutoplay = YES;
[self.view addSubview:movie.view];
[movie setFullscreen:YES animated:YES];
[movie play];
}
and Here is my log
2012-03-16 16:54:39.080 TestVideofile[510:11f03] Get in 2012-03-16
16:54:39.303 TestVideofile[510:11f03] movie path
/Users/crazyoxy/Library/Application Support/iPhone
Simulator/5.1/Applications/7F1425B8-6DB0-4A09-AC8F-3BCDBF19ED95/TestVideofile.app/video3.MOV
2012-03-16 16:54:39.304 TestVideofile[510:11f03] movie <
MPMoviePlayerController: 0x7a8ea30 >
After I click button that link with this IBAction, it turns to black page but didn’t show video or even any audio.
Could you help me please?
You are using ARC and the player gets released if no further references exist.
Adding it as a property to your ViewController instance keeps the instance alive as long as the ViewController is.