Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Moved Creation of AVURLAsset to background thread. #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Source/JukeboxItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ open class JukeboxItem: NSObject {
}

fileprivate func loadAsync(_ completion: @escaping (_ asset: AVURLAsset) -> ()) {
let asset = AVURLAsset(url: URL, options: nil)

asset.loadValuesAsynchronously(forKeys: ["duration"], completionHandler: { () -> Void in
DispatchQueue.main.async {
completion(asset)
}
})
DispatchQueue.global(qos: .background).async {
let asset = AVURLAsset(url: self.URL, options: nil)
asset.loadValuesAsynchronously(forKeys: ["duration"], completionHandler: { () -> Void in
DispatchQueue.main.async {
completion(asset)
}
})
}
}

fileprivate func configureMetadata()
Expand Down