     }
   }
 
-  open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
-    guard let change = change, let value = change[.newKey] as? Float , keyPath == AVAudioSessionOutputVolumeKey else { return }
-
-    updateVolume(Double(value), animated: true)
-  }
-
   deinit {
-    AVAudioSession.sharedInstance().removeObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, context: nil)
     NotificationCenter.default.removeObserver(self)
   }
-
-}
+}


    // If user opted out of animation, toggle observation for the duration of the change
    if !animated {
      AVAudioSession.sharedInstance().removeObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, context: nil)
      
      updateVolume()
      
      DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) { [weak self] in
        guard let `self` = self else { return }
        AVAudioSession.sharedInstance().addObserver(self, forKeyPath: self.AVAudioSessionOutputVolumeKey, options: .new, context: nil)
      }
    } else {
      updateVolume()
    }

  fileprivate func setup() {
    resume()
    updateVolume(Double(AVAudioSession.sharedInstance().outputVolume), animated: false)
    self.audioSessionOutputVolumeObserver = AVAudioSession.sharedInstance().observe(\.outputVolume) { [weak self] (audioSession, _) in
      guard let `self` = self else { return }
      self.updateVolume(Double(audioSession.outputVolume), animated: true)
    }

    backgroundColor = .clear

