ios – Previous PHAsset movies from iCloud do not play

0
16
ios – Previous PHAsset movies from iCloud do not play


On display screen A, I am utilizing a media picker (TLPhotoPicker to be actual) to permit customers to pick a video, which is then handed on to display screen B as a PHAsset so it will probably performed.

In display screen B I’ve performed round with numerous strategies of getting a playable video, they usually 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 screen A, deselect the video, after which reselect it, after which go ahead once more to display screen B, it turns into playable. This makes me suppose that after being fetched from the cloud it is being saved as a distinct PHAsset or one thing, however I’ve in contrast the earlier than and after AVURLAsset.url and PHAsset.localIdentifier on this case they usually do not appear to vary, so I am unsure what is going on on.

As talked about, I’ve tried numerous strategies in display screen B for getting a playable video, akin to:

    let choices = PHContentEditingInputRequestOptions()
    choices.isNetworkAccessAllowed = true
    
    choices.progressHandler = { progress, _ in
        DispatchQueue.important.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.important.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, in contrast to in this submit, I can name these on the AVAsset they usually all the time point out that the video is able to be performed:

let tracks = strive await avAsset.loadTracks(withMediaType: .video) //  tracks exist.
let period = strive await avAsset.load(.period) // period is correct.
let isPlayable = strive await avAsset.load(.isPlayable) // isPlayable is true.

I discovered this submit concerning the situation being that the PHVideoRequestOptions.model must be .authentic, however that also would not work on this edge case.

Any concepts?

LEAVE A REPLY

Please enter your comment!
Please enter your name here