當我從iCloud加載視頻時,我想要更新UIProgressView的進度。出於某種原因,progressHandler不會被調用。我試圖像SamplePhotosApp(它載入圖像)那樣做,但無法使其工作。PHVideoRequestOptions'progressHandler not called
下面是我使用的選項的代碼,並請求視頻:
let videoRequestOptions = PHVideoRequestOptions()
videoRequestOptions.deliveryMode = .FastFormat
videoRequestOptions.version = .Original
videoRequestOptions.networkAccessAllowed = true
videoRequestOptions.progressHandler = { (progress, error, stop, info) in
dispatch_async(dispatch_get_main_queue(), {
print(progress)
self.progressView.progress = Float(progress)
})
}
PHImageManager.defaultManager().requestPlayerItemForVideo(asset, options: videoRequestOptions, resultHandler: {
result, info in
self.videoPlayer = AVPlayer(playerItem: result!)
})
此代碼甚至不會打印出任何東西,所以它看起來像progressHandler塊不會在所有調用。我要求的視頻位於iCloud中,因爲如果networkAccessAllowed設置爲false,它會崩潰。
問題在哪裏?