Skip to content

Commit

Permalink
Fix for app crashing occasionally on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Martibis committed Aug 3, 2020
1 parent 3f95e46 commit fe91e4f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ios/Classes/AvController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ class AvController: NSObject {
}

public func getTrack(_ asset: AVURLAsset)->AVAssetTrack? {
return asset.tracks(withMediaType: AVMediaType.video).first!
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
}

public func getVideoOrientation(_ path:String)-> Int? {
Expand Down

0 comments on commit fe91e4f

Please sign in to comment.