fix pip screen bugs
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import AVFoundation
|
||||
import UIKit
|
||||
import WidgetKit
|
||||
|
||||
@@ -93,9 +94,39 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
guard let message = notification.userInfo?["message"] as? String else { return }
|
||||
HostBridge.shared.showToast(message)
|
||||
}
|
||||
NotificationCenter.default.addObserver(
|
||||
forName: Notification.Name("llmpPrepareAudioSession"),
|
||||
object: nil,
|
||||
queue: .main
|
||||
) { [weak self] _ in
|
||||
self?.activatePlaybackSession()
|
||||
}
|
||||
QqShareHost.shared.prepare()
|
||||
}
|
||||
|
||||
/// iOS 27 起主线程同步 setActive 会报 Hang Risk,改走异步激活。
|
||||
private func activatePlaybackSession() {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try? session.setCategory(.playback)
|
||||
if #available(iOS 27.0, *) {
|
||||
session.activate(options: []) { activated, error in
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(
|
||||
name: Notification.Name("llmpAudioSessionReady"),
|
||||
object: nil,
|
||||
userInfo: ["ok": activated && error == nil]
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try? session.setActive(true)
|
||||
NotificationCenter.default.post(
|
||||
name: Notification.Name("llmpAudioSessionReady"),
|
||||
object: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func application(
|
||||
_ app: UIApplication,
|
||||
open url: URL,
|
||||
|
||||
Reference in New Issue
Block a user