working media player in ios and android

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-28 21:42:53 -07:00
co-authored by Copilot
parent 5e69d8f90a
commit 5363665fd8
12 changed files with 281 additions and 0 deletions
+10
View File
@@ -1,5 +1,6 @@
import Flutter
import UIKit
import AVFoundation
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
@@ -7,6 +8,15 @@ import UIKit
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Ensure iOS uses the playback category so lock screen / Control Center
// media controls remain available during background audio.
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.allowAirPlay])
try AVAudioSession.sharedInstance().setActive(true)
} catch {
NSLog("Failed to configure AVAudioSession: \(error)")
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}