mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Respond to service failure
This commit is contained in:
parent
dbc9f77d9b
commit
a6c4ad95fc
@ -219,11 +219,15 @@ public final class ManagedAudioSession {
|
|||||||
})
|
})
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(forName: AVAudioSession.interruptionNotification, object: AVAudioSession.sharedInstance(), queue: nil, using: { [weak self] notification in
|
NotificationCenter.default.addObserver(forName: AVAudioSession.interruptionNotification, object: AVAudioSession.sharedInstance(), queue: nil, using: { [weak self] notification in
|
||||||
|
managedAudioSessionLog("Interruption received")
|
||||||
|
|
||||||
guard let info = notification.userInfo,
|
guard let info = notification.userInfo,
|
||||||
let typeValue = info[AVAudioSessionInterruptionTypeKey] as? UInt,
|
let typeValue = info[AVAudioSessionInterruptionTypeKey] as? UInt,
|
||||||
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
|
let type = AVAudioSession.InterruptionType(rawValue: typeValue) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
managedAudioSessionLog("Interruption type: \(type)")
|
||||||
|
|
||||||
queue.async {
|
queue.async {
|
||||||
if let strongSelf = self {
|
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 {
|
queue.async {
|
||||||
self.isHeadsetPluggedInValue = self.isHeadsetPluggedIn()
|
self.isHeadsetPluggedInValue = self.isHeadsetPluggedIn()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user