MPMoviePlayerController perfectly works with Ios 4.0 but not working in 4.2
I have implement the MPMoviePlayerController it perfectly working in ios 3.2 and 4.0 but not in Ios 4.2.
What i'm wrong with my code
- (void)viewDidLoad {
NSLog(@"videoSubView viewDidLoad");
moviePlayerController =[[MPMoviePlayerController alloc]initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self
开发者_如何学编程 selector:@selector(exitedFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:moviePlayerController];
moviePlayerController.view.frame = CGRectMake(0,0,320,460);
[self.view addSubview:moviePlayerController.view];
[moviePlayerController play];
[super viewDidLoad];
}
added the MediaPlayer.framework and #import import the mediaplayer in .h file
Please help me.
Thank You
Have you correctly intialised videoURL
?
How are you initialising videoURL? I was having this problem in iOS 5.0 only. Once I changed from doing this:
NSURL* url = [NSURL URLWithString:localFile];
to this:
NSURL* url = [NSURL fileURLWithPath:localFile];
the problem went away.
精彩评论