You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asset.tracks(withMediaType: AVMediaType.video).first! is sometimes crashing the app. Simply initializing the AVAsset is not enough for the asset to be ready to access its tracks.
Platform
IOS
Expected solution
AVAsset needs to be loaded first before accessing any of its tracks.
Here is an example of how to fix it.
public func getTrack(_ asset:AVURLAsset)->AVAssetTrack? {
var track :AVAssetTrack?= nil
let group =DispatchGroup()
group.enter()
asset.loadValuesAsynchronously(forKeys: ["tracks"], completionHandler: {
var error:NSError?= nil;
let status = asset.statusOfValue(forKey:"tracks", error:&error)
if (status == .loaded) {
track = asset.tracks(withMediaType:AVMediaType.video).first
}
group.leave()
})
group.wait()
return track
}
The text was updated successfully, but these errors were encountered:
Description
asset.tracks(withMediaType: AVMediaType.video).first!
is sometimes crashing the app. Simply initializing the AVAsset is not enough for the asset to be ready to access its tracks.Platform
IOS
Expected solution
AVAsset needs to be loaded first before accessing any of its tracks.
Here is an example of how to fix it.
The text was updated successfully, but these errors were encountered: