使用随需应变资源从资产目录获取视频 [英] Getting video from Asset Catalog using On Demand ressources
问题描述
例如,我为.mp4视频分配了"tokyo"标签,并将其设置为在应用安装过程中安装的位置.
I attributed to my .mp4 video the "tokyo" tag for example, and set it as installed during the app installation.
现在,在我使用路径从资源中获取路径之前,现在有所不同,因为它位于资产目录中.
Now before I was using a Path to get it from my resources, now it's different because it's located on the Asset Catalog.
找到文档后,我尝试了类似的方法:
After found documentations, I tried something like :
NSBundleResourceRequest(tags: ["tokyo"]).beginAccessingResourcesWithCompletionHandler { (error) -> Void in
let tokyoVideo = NSDataAsset(name: "tokyo")
所以我可以做:tokyoVideo.data访问NSData,但是我使用的是AVPlayer,它接受一个NSURL参数,而不是数据.
So I can do : tokyoVideo.data to access NSData but I'm using AVPlayer which take in parameter an NSURL, not data.
那么,对于我的视频获得NSURL的建议是什么? 资产目录仅用于数据吗?所以我不能在此处设置视频?
So what can you suggest me for getting a NSURL of my video ? Is the Asset Catalog only for Data ? So I can't set my video there ?
推荐答案
我认为可以将Asset Catalog用于视频内容,它简化了图像管理.为此使用NSDataAsset.查看下表中的最后一行.
I think its possible to use Asset Catalog for video stuff, Its simplify management of images. Use NSDataAsset for it. Review the last row in below table.
The following table lists the types of resources that can be tagged as on-demand resources.
这篇关于使用随需应变资源从资产目录获取视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!