在iPhone 4.0 OS中运行时,带有iPhone 3.0 OS应用程序的视频崩溃

Video with iPhone 3.0 OS application getting crash while running in iphone 4.0 OS

在iphone 4.0 OS中播放视频时出现崩溃问题。 实际上,我已经使用基本的SDK 3.0创建了应用程序,现在我只是将应用程序安装到4.0 OS设备上。

它无法解决该问题...我已经调试了该问题,发现在4.0 OS中,苹果更改了播放视频的框架和方法。

任何人都可以帮助我解决这一问题。

这是我的代码,在3.0 OS中可以正常运行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-(void)play
    {
     NSBundle *bundle = [NSBundle mainBundle];
     //NSString *path = [bundle pathForResource:@"Icon" ofType:@"png"];
     NSString *path = [bundle pathForResource:@"loader" ofType:@"m4v"];
     NSURL *url = [NSURL fileURLWithPath:path];
     moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
     moviePlayer.scalingMode = MPMovieScalingModeAspectFill;

     [[NSNotificationCenter defaultCenter] addObserver:self
                selector:@selector(moviePlayBackDidFinish:)
                 name:MPMoviePlayerPlaybackDidFinishNotification
                  object:moviePlayer];
     moviePlayer.movieControlMode = MPMovieControlModeHidden;
     [moviePlayer play];
    }

提前致谢,
Pragnesh


在iOS4中,您需要使用MPMoviePlayerViewController。 我在这里发布了我的工作代码示例。