Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我正试图从我的资源中播放MP4文件,但它没有播放。帮我修一下_Iphone_Ios - Fatal编程技术网

Iphone 我正试图从我的资源中播放MP4文件,但它没有播放。帮我修一下

Iphone 我正试图从我的资源中播放MP4文件,但它没有播放。帮我修一下,iphone,ios,Iphone,Ios,我正在尝试从我的资源中播放MP4文件,但它没有播放。。。我还得做些什么。帮我修一下 NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil]; NSURL *url = [NSURL fileURLWithPath:urlStr]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWith

我正在尝试从我的资源中播放MP4文件,但它没有播放。。。我还得做些什么。帮我修一下

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(0, 0, 300, 400);  
[moviePlayer play];
尝试而不是

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line.mp4" ofType:nil];
这:


确保您的电影文件不仅列在Project Explorer中,而且还包括在“复制捆绑资源”列表中

您可以通过单击project explorer中的根节点进行检查,选择目标,然后单击“构建阶段”选项卡。完成此操作后,您将看到四个列表,第二个是“复制捆绑资源”列表。您可以使用“构建阶段”选项卡中的“搜索”字段快速查看您的电影是否包含在此列表中。如果不是,请将您的电影文件拖放到此列表中


我目前正在使用Xcode 4.3.2,但这些步骤已经有一段时间没有改变了。希望这些步骤能有所帮助。

不确定不玩是什么意思?你有没有遇到编译错误,等等。我测试了你的代码,在我这方面似乎工作得很好。确保已使用xcode将mp4文件包含在包中。。。
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"line" ofType:@"mp4"];