Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Videos Not working(asset Url is nil) #302

Open
toseef31 opened this issue Jan 22, 2021 · 1 comment
Open

Recent Videos Not working(asset Url is nil) #302

toseef31 opened this issue Jan 22, 2021 · 1 comment

Comments

@toseef31
Copy link

func dismissPhotoPicker(withPHAssets: [PHAsset]) {
    let mutableImages: NSMutableArray! = []
    for asset: PHAsset in withPHAssets
    {
        if asset.mediaType == .video{
            print("  ")
            isSelectedImage = false
            let vData = Data(contentsOf: asset)
            PHImageManager.default().requestAVAsset(forVideo: asset, options: nil, resultHandler: { (asset, mix, nil) in
                let myAsset = asset as? AVURLAsset
                do {
                       // myAsset is nilll here
                    let videoData = try Data(contentsOf: (myAsset?.url)!)

                    DatabaseManager.sharedInstance.sendImage(receiverId: self.msgSenderId, image: #imageLiteral(resourceName: "online"), imageName: "nil", isGroup: self.isGroup, isAudioRec: false, audioData: nil, isVideo: true, videoData: videoData) { (isSent) in
                        if isSent{
                            self.view.makeToast("Sent")
                        }
                    }
                } catch  {
                    print("exception catch at block - while uploading video")
                }
            })
        }
    }

}
@toseef31 toseef31 changed the title Recent Videos Not working Recent Videos Not working(asset Url is nil) Jan 22, 2021
@tilltue
Copy link
Owner

tilltue commented Jan 28, 2021

@peekinternational

https://developer.apple.com/documentation/photokit/phimagemanager/1616935-requestavasset

func requestAVAsset(forVideo asset: PHAsset, 
            options: PHVideoRequestOptions?, 
      resultHandler: @escaping (AVAsset?, AVAudioMix?, [AnyHashable : Any]?) -> Void) -> PHImageRequestID

resultHandler return AVAsset. ( is not AVURLAsset )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants