MPMoviePlayerController和NSURL对象 [英] MPMoviePlayerController and the NSURL object

查看:80
本文介绍了MPMoviePlayerController和NSURL对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pathForResource返回的NSURL对象对于自定义导入的电影文件为null.

The NSURL object returned by pathForResource is null for custom imported movie files.

 -(NSURL *)localMovieURL
{
    NSURL *theMovieURL = nil;
    NSBundle *bundle = [NSBundle mainBundle];
    if (bundle) 
    {
          NSString *moviePath = [bundle pathForResource:@"Movie"      ofType:@"m4v"];
        //NSString *moviePath = [bundle pathForResource:@"Movie_01"   ofType:@"m4v"]; 
        //NSString *moviePath = [bundle pathForResource:@"Sample"     ofType:@"m4v"];
    if (moviePath)
    {   
        theMovieURL = [NSURL fileURLWithPath:moviePath];
        }

    NSLog(@" MMM moviePath   = %@", moviePath);
    NSLog(@" UUU theMovieURL = %@", theMovieURL);

}

return theMovieURL;

}

考虑上述来自Apple的示例代码(示例项目名称-MoviePlayer)

Consider the above sample code from Apple (Sample Project name - MoviePlayer)

https://developer.apple.com/library/ios/navigation/index.html?section=Resource+Types&topic=Sample+Code

Movie.m4v随示例一起提供,并且已编译的示例项目完全可以毫无问题地播放m4v.但是,当我复制Movie.m4v时,将其命名为Movie_01.m4v并将文件拖到项目中,MPMoviePlayerController没有响应.添加的NSLog输出(从MMM和UUU开始也变为"... =(空)".我使用iMovie制作的示例m4v"Sample.m4v"也是如此.

Movie.m4v comes with the sample and the compiled sample project plays the m4v with no problem at all. But when I make a copy of Movie.m4v, name it Movie_01.m4v and drag the file into the project, the MPMoviePlayerController has no response. Also the added NSLog output (begins with MMM and UUU becomes "...= (null)". The same goes for the sample m4v "Sample.m4v" which I make myself with iMovie.

此问题与我之前在(在此处)发布的问题有关.我之前的问题涉及一个我自己编写的项目,并且存在相同的问题:即使看似正确导入了电影文件,"pathForResource"方法也返回"nil".样本电影都可以在Xcode中完美播放,并且我以相同的方式将png照片文件导入(拖动)到项目中.但是png照片可以通过编译程序按预期方式在手机和模拟器上显示.

This question is related to the question I posted earlier (here). My previous question involves a project which I wrote myself and it has the same problem : The "pathForResource" method returns "nil" even the movie files are seemingly properly imported. The sample movies can all play perfectly inside Xcode and I have imported (drag) png photo files into the project in the same way. But the png photos can be displayed by the compiled program both on the phone and the simulator as expected.

希望有人可以提供一些提示.

Hope somebody can give some hints.

推荐答案

似乎您重复了问题.这两个答案似乎都是:将影片添加到您的应用程序捆绑包中(项目构建步骤">复制资源")

It seems you duplicated your question. Both answers seems to be: add the movie to your application bundle (Project Build Steps > Copy Resources)

这篇关于MPMoviePlayerController和NSURL对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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