Per alcuni video, requestImageForAsset viene completato con un UIImage che è nullo. Per altri video funziona bene e non ho ancora capito perché.PHImageManager.requestImageForAsset restituisce nil quando si crea una miniatura per il video
func createThumbnailForVideo(video: PHAsset) -> Future<NSURL> {
let promise = Promise<NSURL>()
let options = PHImageRequestOptions()
options.synchronous = true
imageManager.requestImageForAsset(video, targetSize: CGSizeMake(640, 640), contentMode: .AspectFill, options: options) { (image:UIImage!, info) -> Void in
if image == nil {
println("Error: Couldn't create thumbnail for video")
promise.error(MyErrors.videoThumb())
} else {
if let thumbURL = self.savePhotoAsTemporaryFile(image) {
promise.success(thumbURL)
} else {
promise.error(MyErrors.videoThumb())
}
}
}
return promise.future
}
ho anche tornare informazioni per la richiesta, ma non so come interpretare le informazioni:
[PHImageResultIsDegradedKey: 0, PHImageResultWantedImageFormatKey: 4037, PHImageResultIsPlaceholderKey: 0, PHImageResultIsInCloudKey: 0, PHImageResultDeliveredImageFormatKey: 9999]
Sembra un bug, soprattutto se è specifico per alcuni video e non per altri. [L'hai segnalato] (http://bugreport.apple.com)? – rickster
Non ho segnalato come non ero sicuro che fosse un bug. Credo di poterlo fare, ma l'ultimo che ho segnalato era di nuovo in ottobre e non ho più avuto notizie. Rispondono alle segnalazioni di bug? –