首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MPMoviePlayercontroller没有在iphone 4中工作?-需要帮助

问MPMoviePlayercontroller没有在iphone 4中工作?-需要帮助
EN

Stack Overflow用户
提问于 2010-06-23 07:20:12
回答 1查看 5.2K关注 0票数 1

直到昨天,我的MPMovieController还在iPhone SDK 3中被唤醒。但是昨天,当我升级了SDK ti iphone 4时,我的电影播放器停止工作了,它在下面的行上给了我一个不推荐的警告(他们已经废弃了很多方法)

代码语言:javascript
复制
moviePlayer.movieControlMode = MPMovieControlModeDefault;

我的完整代码如下:

代码语言:javascript
复制
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];
    }

请告诉我哪种方法可以代替不推荐的方法,或者应该做一些不同的事情?

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-06-23 08:56:32

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

代码语言:javascript
复制
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];
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3099662

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档