Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Oct 15, 2023
1 parent 8e5e03c commit d7fe33c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Demo/SwiftUI/Shared/MovieModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import CoreData
import CoreMedia
import Foundation
import KSPlayer
#if canImport(UIKit)
Expand Down
9 changes: 5 additions & 4 deletions Sources/KSPlayer/AVPlayer/KSOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,16 @@ public extension KSOptions {
return Int(ncpu)
}

internal static func setAudioSession() {
static func setAudioSession() {
#if os(macOS)
// try? AVAudioSession.sharedInstance().setRouteSharingPolicy(.longFormAudio)
#else
let category = AVAudioSession.sharedInstance().category
if category != .playback, category != .playAndRecord {
try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, policy: .longFormAudio)
if category == .playback || category == .playAndRecord {
try? AVAudioSession.sharedInstance().setCategory(category, mode: .moviePlayback, policy: .longFormAudio)
} else {
try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback, policy: .longFormAudio)
}
try? AVAudioSession.sharedInstance().setMode(.moviePlayback)
try? AVAudioSession.sharedInstance().setActive(true)
#endif
}
Expand Down

0 comments on commit d7fe33c

Please sign in to comment.