我做的是iOS开发。
需要实现的功能: 从手机相册中导入视频文件到我的APP中(后续会对这个文件进行操作).
遇到的障碍:我拿不到相册中的视频文件的实际地址(文件路径),最多只能拿到它在相册中的URL。
求大神帮忙解决下问题,感激不尽。
以下是我的部分代码,我需要再注释处获得文件路径:
-(void)assetPickerController:(ZYQAssetPickerController )picker didFinishPickingAssets:(NSArray )assets{
//TODO:
for (ALAsset *asset in assets) {
NSLog(@"HERE\n asset.defaultRepresentation.url = %@\n asset.defaultRepresentation.filename = %@",asset.defaultRepresentation.url, asset.defaultRepresentation.filename);
[self saveVideoToApp:nil asset:asset];
// 我想在这里拿到视频文件
}
}
以下是我的打印数据
2015-11-13 20:51:57.556 MyApp[1244:499923] HERE
asset.defaultRepresentation.url = assets-library://asset/asset.MOV?id=08A49AFB-8FA6-4F69-824F-A34CB168CAAA&ext=MOV
asset.defaultRepresentation.filename = IMG_0006.MOV
多谢
Dude, has the problem been solved? Can you give me some ideas?
The specific path of the file in the system album cannot be obtained through ALAsset. The general method is to directly obtain the video data through ALAssetRepresentation. If a fileURL is also needed, the video data can be written into a custom fileURL file. Sample code As follows:
. . . Why hasn't it been resolved yet?
First you play this file, there is no need to export it at all!
This AVAsset can be used for playback, editing, etc.
Then if you need to go anywhere, you can use
Then this method can add a lot of parameters to help you export. For details, you can look at AVComposition, huh.