MPMoviePlayercontroller在iphone SDK 4中不起作用? - 需要帮助 [英] MPMoviePlayercontroller not working in iphone SDK 4 ? - Help Needed

查看:71
本文介绍了MPMoviePlayercontroller在iphone SDK 4中不起作用? - 需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到昨天,我的MPMovieController在 iPhone SDK 3 中运行正常.但是昨天,当我升级SDK ti iphone SDK 4 时,我的电影播放器​​停止工作了,它在下一行向我发出了弃用警告(他们已弃用了许多方法)

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;

我的完整代码如下:

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 ?

谢谢,

推荐答案

我今天早上才使用MPMoviePlayerController,并且此代码运行良好(仅在iPad模拟器上进行了测试)

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

这篇关于MPMoviePlayercontroller在iphone SDK 4中不起作用? - 需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆