通过assetURL获取到视频

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZuoWeiXiaoDuZuoZuo/article/details/78803007

title: 通过assetURL获取到视频
date: 2017-12-14 15:02:47
tags: 原创分享

首先导入头文件

#import <Photos/Photos.h>

iOS中assetURL样式:

assets-library://asset/asset.mov?id=F2E6E143-4343-4B57-87F9-346936E0EDB3&ext=mov

使用当前的URL过滤到我们想要的数据

 	PHFetchResult *result = [PHAsset fetchAssetsWithALAssetURLs:@[assetUrl] options:nil];

    PHAsset * PHAsset = result.firstObject;

    /// 包含该视频的基础信息
    PHAssetResource * resource = [[PHAssetResource assetResourcesForAsset: PHAsset] firstObject];

    NSLog(@"%@",resource);
    PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
    options.version = PHImageRequestOptionsVersionCurrent;
    options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
    
    PHImageManager *manager = [PHImageManager defaultManager];
    [manager requestAVAssetForVideo:asset
                            options:options
                      resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
                          AVURLAsset *vedioUrlAsset = (AVURLAsset *)asset;
                          NSURL *vedioUrl = vedioUrlAsset.URL;
                          NSData *data = [NSData dataWithContentsOfURL:vedioUrl];
   
                      }];


阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页