开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜