的MPMoviePlayerController不是在iPhone SDK 4个工作? - 需要

2019-10-23 11:24发布

直到昨天我MPMovieController在iPhone SDK 3工作呢罚款。 不过,昨天当我升级了TI SDK iPhone的SDK 4我movieplayer停止工作,它给我上以下行产生警告(他们不赞成大量的方法)

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];
    }

请告诉我,而不是取代过时的方法,哪种方法还是应该做不同的事情?

谢谢 ,

Answer 1:

今天早上我刚用过的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];


文章来源: MPMoviePlayercontroller not working in iphone SDK 4 ? - Help Needed