   fileprivate func setup() {
     resume()
     updateVolume(Double(AVAudioSession.sharedInstance().outputVolume), animated: false)
-    AVAudioSession.sharedInstance().addObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, options: .new, context: nil)
+    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
 

    }
  }

  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)
  }

}

  fileprivate let volume = MPVolumeView(frame: CGRect.zero)
  fileprivate let overlay = UIView()
  public fileprivate(set) var volumeLevel = Double(0)
  open static let DefaultVolumeStep: Double = 0.05
  
  private var audioSessionOutputVolumeObserver: Any?
  private var reenableOutputVolumeObservationWorkItem: DispatchWorkItem?

  @objc convenience public init(style: SubtleVolumeStyle, frame: CGRect) {
    self.init(frame: frame)
