MPMoviePlayercontroller not working in iphone SDK 4 ? - Help Needed

那年仲夏 提交于 2019-12-11 09:13:22

问题


Till yesterday My MPMovieController was wokring fine in iPhone SDK 3 . But yesterday when I upgraded the SDK ti iphone SDK 4 my movieplayer stops working it is giving me a deprecation warning on the following line (They have deprecated lots of methods )

moviePlayer.movieControlMode = MPMovieControlModeDefault;

My full code is as follows :

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

please Tell me which method to replace instead of the deprecated method or should do something different ?

Thanks ,


回答1:


I used the MPMoviePlayerController just this morning and this code works good (tested on iPad simulator only)

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


来源:https://stackoverflow.com/questions/3099662/mpmovieplayercontroller-not-working-in-iphone-sdk-4-help-needed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!