iPhone 3.0操作系统应用程序的视频在iphone 4.0操作系统中运行时崩溃

时间:2010-07-07 04:18:09

标签: iphone video operating-system mpmovieplayercontroller iphone-4

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

它不起作用......我调试了这个问题,发现在4.0操作系统中,苹果改变了播放视频的框架和方法。

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

这是我在3.0操作系统中正常运行的代码。

-(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

1 个答案:

答案 0 :(得分:1)

使用iOS4,您需要使用MPMoviePlayerViewController。我发布了working code sample here