AVPlayer不在iOS 8中加载视频(AVPlayer not loading video in iOS 8)

编程入门 行业动态 更新时间:2024-10-25 13:17:37
AVPlayer不在iOS 8中加载视频(AVPlayer not loading video in iOS 8) AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init]; playerViewController.player = [AVPlayer playerWithURL:[[NSBundle mainBundle] URLForResource:@"Besan" withExtension:@"mp4"]]; [playerViewController.player play];

我试图在iOS 8中使用AVPlayerViewController,但视频无法加载。 我只是获得下面的屏幕。

整个代码库位于https://github.com/sairamsankaran/AVPlayerDemo

AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init]; playerViewController.player = [AVPlayer playerWithURL:[[NSBundle mainBundle] URLForResource:@"Besan" withExtension:@"mp4"]]; [playerViewController.player play];

I am trying to use the AVPlayerViewController in iOS 8. But the video does not load. I simply get the screen below.

The entire codebase is here https://github.com/sairamsankaran/AVPlayerDemo

最满意答案

我下载你的项目并看看。 这个解决方案非常简单,你忘了将视频文件包含在你的目标中,这意味着当你设置的URL指向一个不存在的文件时,这意味着NSURL为零。

在Xcode的实用程序侧栏中,选择导航器中的mp4文件,选择文件检查器,然后在“目标成员”中确保检查您的应用目标。

完成此操作后,您的电影将在发布时播放。

I download your project and had a look. The solution is pretty simple, you forgot to include the video file in your target, which means when you're setting up the URL you're pointing to a file that doesn't exist, which means the NSURL is nil.

In the Utilities side bar in Xcode, with your mp4 file chosen in the navigator, choose the File Inspector and in "Target Membership" be sure to check your app target.

Once you have done this your movie will play on launch.

更多推荐

本文发布于:2023-08-07 03:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1460717.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   视频   iOS   AVPlayer   loading

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!