Mediaplayer框架无法在iOS 6中播放视频 [英] mediaplayer framework not playing video in iOS 6

查看:114
本文介绍了Mediaplayer框架无法在iOS 6中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS 6中包含的mediaplayer框架来尝试从应用程序中播放电影.我导入,然后:

I am using the mediaplayer framework included in iOS 6 to try and play a movie from within an app. I import and then:

-(IBAction)playMovie:(id)sender
{
    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"buyTutorial" ofType:@"mov"];
    NSURL *fileURL = [NSURL fileURLWithPath:filepath];
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    [self.view addSubview:moviePlayerController.view];
    moviePlayerController.fullscreen = YES;
    [moviePlayerController play];
}

调用此函数时,视图将进入空白屏幕并无限加载.我尝试了此实现的许多其他版本,结果各不相同,并且全部失败.特殊情况下的日志为:

The view goes to blank screen and infinite loading when this function is called. I have tried many other versions of this implementation and the results vary and all fail. The log in the is particular case is:

2012-11-05 21:19:27.900 [MPAVController] Autoplay: Disabling autoplay for pause
2012-11-05 21:19:27.902 [MPAVController] Autoplay: Disabling autoplay
2012-11-05 21:19:27.977 [MPAVController] Autoplay: Disabling autoplay for pause
2012-11-05 21:19:27.978 [MPAVController] Autoplay: Disabling autoplay
2012-11-05 21:19:27.984 [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
2012-11-05 21:19:28.156 [MPAVController] Autoplay: Enabling autoplay

关于原因有什么想法?这是我第一次尝试播放视频,到现在为止,这真是一场噩梦.

Got ideas on the cause? This is my first venture into playing video and it has turned out to be a nightmare at this point.

推荐答案

在.h文件中添加以下内容

In .h file add the following

@property (nonatomic, strong) MPMoviePlayerController *controller;

尝试

 -(IBAction)playMovie:(id)sender
    {
        NSString *filepath = [[NSBundle mainBundle] pathForResource:@"buyTutorial" ofType:@"mov"];
        NSURL *fileURL = [NSURL fileURLWithPath:filepath];
        MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
        [self.view addSubview:moviePlayerController.view];
        moviePlayerController.fullscreen = YES;
    [moviePlayerController prepareToPlay];
        [moviePlayerController play];
[self setController:moviePlayerController];
    }

这篇关于Mediaplayer框架无法在iOS 6中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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