Check given PHAsset is iCloud asset?

后端 未结 6 1170
再見小時候
再見小時候 2021-02-02 14:16

I\'m trying to get PhAsset object. I want to segregate iCloud assets. Here is my code,

PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithT         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 14:54

    Here is the Swift 3 version

    func checkVideoType(){
        if selectedAsset != nil {
            guard (selectedAsset.mediaType == .video) else {
                print("Not a valid video media type")
                return
            }
            requestID = checkIsiCloud(assetVideo:selectedAsset, cachingImageManager: catchManager)
        }
    }
    
     func checkIsiCloud(assetVideo:PHAsset,cachingImageManager:PHCachingImageManager) -> PHImageRequestID{
    
            let opt=PHVideoRequestOptions()
            opt.deliveryMode = .mediumQualityFormat
            opt.isNetworkAccessAllowed=true //iCloud video can play
            return cachingImageManager.requestAVAsset(forVideo:assetVideo, options: opt) { (asset, audioMix, info) in
    
                DispatchQueue.main.async {
                    if (info!["PHImageFileSandboxExtensionTokenKey"] != nil) {
                        self.iCloudStatus=false
                        self.playVideo(videoAsset:asset!)
                    }else if((info![PHImageResultIsInCloudKey]) != nil) {
                        self.iCloudStatus=true
    
                    }else{
                       self.iCloudStatus=false
                       self.playVideo(videoAsset:asset!)
                    }
                }
        }
    
    }
    

提交回复
热议问题