swift兩種擷取相簿資源PHAsset的路徑的方法(絕對路徑)

來源:互聯網
上載者:User

標籤:phi   color   handle   and   efi   file   nts   info   bsp   

方法中使用到的phasset就是我們取到的PHAsset對象

方法一:

 1 let options = PHVideoRequestOptions() 2  3 options.version = PHVideoRequestOptionsVersion.current 4  5 options.deliveryMode = PHVideoRequestOptionsDeliveryMode.automatic 6  7 let manager =PHImageManager.default() 8  9 manager.requestAVAsset(forVideo: phasset, options: options, resultHandler: { (asset, audioMix, info) in10 11        let strArr =     ((info!asNSDictionary).object(forKey:"PHImageFileSandboxExtensionTokenKey")as!NSString).components(separatedBy:";")12 13        let url = strArr.last!14 15        print(url)16 17 })

 

方法二(比較簡潔):

1 PHCachingImageManager().requestAVAsset(forVideo: phasset as PHAsset, options:nil, resultHandler: { (asset, audioMix, info) in2 3          let strArr =     ((info!asNSDictionary).object(forKey:"PHImageFileSandboxExtensionTokenKey")as!NSString).components(separatedBy:";")4 5         let url = strArr.last!6 7         print(url)8 9 })

 

 

swift兩種擷取相簿資源PHAsset的路徑的方法(絕對路徑)

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.