         }
         NotificationCenter.default.removeObserver(self)
     }
-  }
-
-  fileprivate func getSelectedMediaOptionWithCharacteristic(_ characteristic: String) -> AVMediaSelectionOption? {
-    if let group = mediaSelectionGroup(characteristic) {
-      return player?.currentItem?.selectedMediaOption(in: group)
-    }
-    return nil
-  }
-  
-  fileprivate func mediaSelectionGroup(_ characteristic: String) -> AVMediaSelectionGroup? {
-    return player?.currentItem?.asset.mediaSelectionGroup(forMediaCharacteristic: characteristic)
-  }
-  
-  deinit {
-    removeObservers()
-  }
-  
-  fileprivate func removeObservers() {
-    if player != nil {
-      player?.removeObserver(self, forKeyPath: "currentItem.status")
-      player?.removeObserver(self, forKeyPath: "currentItem.loadedTimeRanges")
-      player?.removeObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp")
-      player?.removeObserver(self, forKeyPath: "currentItem.playbackBufferEmpty")
-      player?.removeObserver(self, forKeyPath: "externalPlaybackActive")
-    }
-    NotificationCenter.default.removeObserver(self)
-  }
+
+    fileprivate func getSelectedMediaOptionWithCharacteristic(_ characteristic: String) -> AVMediaSelectionOption? {
+        if let group = mediaSelectionGroup(characteristic) {
+            return player?.currentItem?.selectedMediaOption(in: group)
+        }
+        return nil
+    }
+  
+    fileprivate func mediaSelectionGroup(_ characteristic: String) -> AVMediaSelectionGroup? {
+        return player?.currentItem?.asset.mediaSelectionGroup(forMediaCharacteristic: characteristic)
+    }
+  
+    deinit {
+        removeObservers()
+    }
+  
+    fileprivate func removeObservers() {
+        if player != nil {
+            player?.removeObserver(self, forKeyPath: "currentItem.status")
+            player?.removeObserver(self, forKeyPath: "currentItem.loadedTimeRanges")
+            player?.removeObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp")
+            player?.removeObserver(self, forKeyPath: "currentItem.playbackBufferEmpty")
+            player?.removeObserver(self, forKeyPath: "externalPlaybackActive")
+        }
+        NotificationCenter.default.removeObserver(self)
+    }
 }

    return mediaGroup.options.flatMap({MediaOptionFactory.fromAVMediaOption($0, type: .audioSource)})
  }

  open override var isPlaying: Bool {
    if let concretePlayer = player {
      return concretePlayer.rate > 0;
    }

    return false;
  }

  open override var isPaused: Bool {
    return currentState == .paused
  }

  open override var isBuffering: Bool {
    return currentState == .buffering
  }

  open override var duration: Double {
    guard playbackType == .vod, let item = player?.currentItem else {
      return 0
    }
    return CMTimeGetSeconds(item.asset.duration)
  }

    open override class func canPlay(_ options: Options) -> Bool {
        var mimeType = ""

            player?.currentItem?.select(option, in: group)
        }
    }
  
    fileprivate func handleBufferingEvent(_ keyPath: String?) {
        guard let keyPath = keyPath, currentState != .paused else {
            return
        }

    fileprivate func getSelectedMediaOptionWithCharacteristic(_ characteristic: String) -> AVMediaSelectionOption? {
        if let group = mediaSelectionGroup(characteristic) {
