Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load asset before getting its tracks (fixes #60) #61

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion ios/Classes/AvController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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