Video thumbnail taking 10-15 secs to display

后端 未结 1 1923
天命终不由人
天命终不由人 2021-01-28 19:42

I am using DKImagePickerController to select the video from gallery and trying to show a thumbnail of it. Don\'t know why, but it\'s taking 10-15 sec to display the image. Any h

1条回答
  •  生来不讨喜
    2021-01-28 19:45

    The problem is that you are calling thumbnailForVideoAtURL on a background thread. You need to be on the main thread because you are talking to the interface.

    tempDkAsset.fetchAVAssetWithCompleteBlock { (tempVideo, info) in
        DispatchQueue.main.async {
            tempImageView.image = self.thumbnailForVideoAtURL(tempVideo!)
        }
    }  
    

    0 讨论(0)
提交回复
热议问题