1

直到昨天,我的 MPMovieController 在iPhone SDK 3中运行良好。但是昨天当我升级 SDK ti iphone SDK 4时,我的电影播放器​​停止工作,它在下一行给了我一个弃用警告(他们已经弃用了很多方法)

moviePlayer.movieControlMode = MPMovieControlModeDefault;

我的完整代码如下:

NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/videos/%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SERVICE_URL"]
                                           ,customObject.movieURL]];

    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    if (mp)
    {
        // save the movie player object
        self.moviePlayer = mp;

        moviePlayer.movieControlMode = MPMovieControlModeDefault;
        [mp release];

        // Apply the user specified settings to the movie player object


        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(myMovieFinishedCallback:) 
                                                     name:MPMoviePlayerPlaybackDidFinishNotification
                                                   object:moviePlayer];


        // Play the movie!
        [self.moviePlayer play];
    }

请告诉我要替换哪种方法而不是不推荐使用的方法或者应该做一些不同的事情?

谢谢 ,

4

1 回答 1

3

我今天早上使用了 MPMoviePlayerController,这段代码运行良好(仅在 iPad 模拟器上测试)

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"video.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(50, 50, 200, 200);  
[moviePlayer play];
于 2010-06-23T08:56:32.487 回答