feat: 🎸 add exception catch

This commit is contained in:
陈曦 2022-07-27 21:34:08 +08:00
parent fcea0ffcea
commit cee650c84c

View File

@ -268,10 +268,13 @@ enum RCTVideoUtils {
static func preparePHAsset(uri: String) -> Promise<AVAsset?> {
return Promise<AVAsset?>(on: .global()) { fulfill, reject in
let assetId = String(uri[uri.index(uri.startIndex, offsetBy: "ph://".count)...])
let phAsset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
guard let phAsset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject else {
reject(NSError(domain: "", code: 0, userInfo: nil))
return
}
let options = PHVideoRequestOptions()
options.isNetworkAccessAllowed = true
PHCachingImageManager().requestAVAsset(forVideo: phAsset!, options: options) { data, _, _ in
PHCachingImageManager().requestAVAsset(forVideo: phAsset, options: options) { data, _, _ in
fulfill(data)
}
}