On display A, I am utilizing a media picker (TLPhotoPicker to be precise) to permit customers to pick a video, which is then handed on to display B as a PHAsset so it will probably performed.
In display B I’ve performed round with varied strategies of getting a playable video, and so they all work effectively aside from one edge case: actually previous movies which might be saved within the cloud aren’t playable, even after having been downloaded. The emphasis right here is on actually previous, as more moderen cloud movies that have to be fetched from the cloud are playable.
The unusual factor is that after fetching the actually previous cloud video, if I’m going again to display A, deselect the video, after which reselect it, after which go ahead once more to display B, it turns into playable. This makes me assume that after being fetched from the cloud it is being saved as a special PHAsset or one thing, however I’ve in contrast the earlier than and after AVURLAsset.url and PHAsset.localIdentifier on this case and so they do not appear to alter, so I am undecided what is going on on.
As talked about, I’ve tried varied strategies in display B for getting a playable video, akin to:
let choices = PHContentEditingInputRequestOptions()
choices.isNetworkAccessAllowed = true
choices.progressHandler = { progress, _ in
DispatchQueue.principal.async {
self.loadingProgress = progress
}
}
phAsset.requestContentEditingInput(with: choices) { enter, data in
if let enter,
let urlAsset = enter.audiovisualAsset as? AVURLAsset {
let url = urlAsset.url
// play video from url...
} else {
// throw error...
}
}
and
let choices = PHVideoRequestOptions()
choices.model = .authentic
choices.deliveryMode = .highQualityFormat
choices.isNetworkAccessAllowed = true
choices.progressHandler = { progress, error, cease, data in
DispatchQueue.principal.async {
self.loadingProgress = progress
}
}
let supervisor = PHImageManager()
supervisor.requestAVAsset(forVideo: phAsset, choices: choices) { avAsset, cease, data in
if let avAsset {
// play video from AVAsset...
} else {
// throw error...
}
}
No errors are ever thrown. The progress completes to 1.0 (ie 100%) as anticipated. Even stranger is that, not like in this put up, I can name these on the AVAsset and so they all the time point out that the video is able to be performed:
let tracks = strive await avAsset.loadTracks(withMediaType: .video) // tracks exist.
let length = strive await avAsset.load(.length) // length is correct.
let isPlayable = strive await avAsset.load(.isPlayable) // isPlayable is true.
I discovered this put up concerning the subject being that the PHVideoRequestOptions.model needs to be .authentic, however that also would not work on this edge case.
Any concepts?
