fix: iOS静音模式无声
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import UIKit
|
||||
import Flutter
|
||||
import AVFoundation
|
||||
|
||||
@UIApplicationMain
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
@ -8,6 +9,14 @@ import Flutter
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
|
||||
// 设置音频会话类别,确保在静音模式下播放音频
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setCategory(.playback, options: [.duckOthers])
|
||||
} catch {
|
||||
print("Failed to set audio session category: \(error)")
|
||||
}
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user