使用AVPlayer播放本地视频文件

4
我的应用程序中有一个小视频部分。
于是我找到了这个示例,可以从URL播放mp4视频:http://www.sdkboy.com/?p=66 你可以在这里下载示例:http://www.sdkboy.com/tutorials/AVFoundation_Test3.zip 但是当我替换NSURL代码时,出现了问题。
NSURL *url = [NSURL URLWithString:@"http://www.samkeeneinteractivedesign.com/videos/littleVid3.mp4"];

使用此方法播放本地视频时,播放器无法正常工作。

NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"malina36" ofType:@"mp4"]];

这个文件存在,我用

进行了检查。

if ([[NSFileManager defaultManager] fileExistsAtPath:url.absoluteString]) {
        NSLog(@"yes");
    } else {
        NSLog(@"no");
    }

你能帮我吗?


可能是重复的问题:URLWithString返回nil的资源路径 - iPhone - Mike Abdullah
1个回答

16

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接