Disable local video in background.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent ae1a97196e
commit 40b3d038db

@ -183,6 +183,33 @@ protocol CallServiceObserver: class {
super.init() super.init()
self.callUIAdapter = CallUIAdapter(callService: self, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter) self.callUIAdapter = CallUIAdapter(callService: self, contactsManager: contactsManager, notificationsAdapter: notificationsAdapter)
NotificationCenter.default.addObserver(self,
selector:#selector(didEnterBackground),
name:NSNotification.Name.UIApplicationDidEnterBackground,
object:nil)
NotificationCenter.default.addObserver(self,
selector:#selector(didBecomeActive),
name:NSNotification.Name.UIApplicationDidBecomeActive,
object:nil)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
func didEnterBackground() {
AssertIsOnMainThread()
Logger.info("\(self.TAG) \(#function)")
self.updateIsVideoEnabled()
}
func didBecomeActive() {
AssertIsOnMainThread()
Logger.info("\(self.TAG) \(#function)")
self.updateIsVideoEnabled()
} }
// MARK: - Class Methods // MARK: - Class Methods
@ -1069,6 +1096,7 @@ protocol CallServiceObserver: class {
// support or emulation (http://goo.gl/rHAnC1) so don't bother // support or emulation (http://goo.gl/rHAnC1) so don't bother
// trying to open a local stream. // trying to open a local stream.
return (!Platform.isSimulator && return (!Platform.isSimulator &&
UIApplication.shared.applicationState != .background &&
call != nil && call != nil &&
call!.state == .connected && call!.state == .connected &&
call!.hasLocalVideo) call!.hasLocalVideo)

Loading…
Cancel
Save