mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Respond to service failure
This commit is contained in:
parent
dbc9f77d9b
commit
a6c4ad95fc
1 changed files with 15 additions and 0 deletions
|
|
@ -219,11 +219,15 @@ public final class ManagedAudioSession {
|
|||
})
|
||||
|
||||
NotificationCenter.default.addObserver(forName: AVAudioSession.interruptionNotification, object: AVAudioSession.sharedInstance(), queue: nil, using: { [weak self] notification in
|
||||
managedAudioSessionLog("Interruption received")
|
||||
|
||||
guard let info = notification.userInfo,
|
||||
let typeValue = info[AVAudioSessionInterruptionTypeKey] as? UInt,
|
||||
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
|
||||
return
|
||||
}
|
||||
|
||||
managedAudioSessionLog("Interruption type: \(type)")
|
||||
|
||||
queue.async {
|
||||
if let strongSelf = self {
|
||||
|
|
@ -233,6 +237,17 @@ public final class ManagedAudioSession {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
NotificationCenter.default.addObserver(forName: AVAudioSession.mediaServicesWereLostNotification, object: AVAudioSession.sharedInstance(), queue: nil, using: { [weak self] _ in
|
||||
managedAudioSessionLog("Media Services were lost")
|
||||
queue.after(1.0, {
|
||||
if let strongSelf = self {
|
||||
if let (type, outputMode) = strongSelf.currentTypeAndOutputMode {
|
||||
strongSelf.setup(type: type, outputMode: outputMode, activateNow: true)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
queue.async {
|
||||
self.isHeadsetPluggedInValue = self.isHeadsetPluggedIn()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue