mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-05 09:09:46 +00:00
who tf does this work 😭
This commit is contained in:
parent
cd84d5f3fa
commit
728b7a0d45
1 changed files with 6 additions and 6 deletions
|
|
@ -2159,14 +2159,14 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": request.allHTTPHeaderFields ?? [:]])
|
||||
let playerItem = AVPlayerItem(asset: asset)
|
||||
|
||||
var audioApplied = false
|
||||
let audioTrackToApply = lastSelectedAudioTrack
|
||||
let observer = playerItem.observe(\.status, options: [.new]) { [weak self] item, change in
|
||||
let observer = playerItem.observe(\.status, options: [.new]) { [weak self] item, _ in
|
||||
guard let self = self else { return }
|
||||
if item.status == .readyToPlay, !audioApplied {
|
||||
audioApplied = true
|
||||
if let lastAudio = audioTrackToApply {
|
||||
self.switchToAudioTrack(named: lastAudio)
|
||||
if item.status == .readyToPlay {
|
||||
if let audioTrackName = audioTrackToApply,
|
||||
let group = item.asset.mediaSelectionGroup(forMediaCharacteristic: .audible),
|
||||
let option = group.options.first(where: { $0.displayName == audioTrackName }) {
|
||||
playerItem.select(option, in: group)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue