无法播放mainBundle的MP4视频文件 [英] Unable to play MP4 video file from mainBundle

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

问题描述

所以我正在尝试播放一个简单的介绍动画视频文件,我已将其拖入我的XCode项目中,因此应该能够从我的mainBundle播放,对吗?

So I'm trying to play a simple intro animation video file that I've dragged into my project in XCode and therefore should be able to play from my mainBundle, right?

使用以下代码:

 NSURL *urlString = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"introvideo" ofType:@"mp4"]]; 
MPMoviePlayerController *player  = [[MPMoviePlayerController alloc] initWithContentURL:urlString];
[player play];

我收到以下错误消息:
*由于未捕获的异常而终止应用NSInvalidArgumentException',原因:'* - [NSURL initFileURLWithPath:]:nil字符串参数'

I get this error message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'

任何帮助都会很棒!

推荐答案

这意味着您的代码找不到您的introvideo.mp4文件。确保您已成功将该文件添加到捆绑包中。您可以签入项目的设置:复制捆绑资源。

This means your code can't find your introvideo.mp4 file. Make sure you have successfully add that file to your bundle. You can check in your project's setting: Copy Bundle Resource.

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

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