简体   繁体   English

无法从“照片”框架从视频资产的URL获取数据

[英]Unable to fetch data from URL of video Asset from Photos framework

I'm stuck with this error. 我陷入了这个错误。

Error Domain=NSCocoaErrorDomain Code=257 "The file “IMG_4156.MP4” couldn't be opened because you don't have permission to view it." 错误域= NSCocoaErrorDomain代码= 257“无法打开文件“ IMG_4156.MP4”,因为您没有查看权限。”

UserInfo={NSFilePath=/var/mobile/Media/DCIM/104APPLE/IMG_4156.MP4, NSUnderlyingError=0x160ebd8f0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} UserInfo = {NSFilePath = / var / mobile / Media / DCIM / 104APPLE / IMG_4156.MP4,NSUnderlyingError = 0x160ebd8f0 {Error Domain = NSPOSIXErrorDomain Code = 1“不允许操作”}}

I'm trying to extract Data from a url of video asset from the Photo's framework which is something like this : file:///var/mobile/Media/DCIM/104APPLE/IMG_4155.MP4 我正在尝试从照片框架中的视频资产网址中提取数据,如下所示:file:///var/mobile/Media/DCIM/104APPLE/IMG_4155.MP4

However I m successful in extracting photos using the same method not the videos.. 但是,我使用相同的方法而非视频成功提取了照片。

I m using these lines to extract the video : 我正在使用这些行提取视频:

let urlNew = URL(fileURLWithPath: item.finalVideoForServer)
let videoData = try Data(contentsOf: urlNew)

Kindly help me or correct me if I'm wrong. 如果我错了,请帮助我或纠正我。

You have to add following lines to your info.plist file(open in source code view) in your project directory 您必须在项目目录中的info.plist文件(在源代码视图中打开)中添加以下行

<!-- 🖼 Photo Library -->
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) photo use</string>

<!-- 📷 Camera -->
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) camera use</string>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM