Skip to content

Commit

Permalink
try AVAudioSession
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jul 30, 2024
1 parent 693b962 commit 044c52d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import Flutter
import AVFoundation

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -8,6 +9,18 @@ import Flutter
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

// 配置音频会话
do {
if #available(iOS 10.0, *) {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
}
} catch {
print("Error setting up audio session: \(error)")
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

0 comments on commit 044c52d

Please sign in to comment.