         Logger.logDebug("destroying", scope: "Player")
         baseObject.stopListening()
         Logger.logDebug("destroying core", scope: "Player")
-        self.core?.destroy()
+        core?.destroy()
         Logger.logDebug("destroying viewController", scope: "Player")
         destroyViewController()
         Logger.logDebug("destroyed", scope: "Player")
     }
 
-    fileprivate func destroyViewController() {
-        if let viewController = viewController {
-            viewController.player = nil
-            viewController.willMove(toParent: nil)
-            viewController.view.removeFromSuperview()
-            viewController.removeFromParent()
-        }
-
+    private func destroyViewController() {
         willMove(toParent: nil)
         view.removeFromSuperview()
         removeFromParent()


open class Player: AVPlayerViewController {
    open var playbackEventsToListen: [String] = []
    fileprivate var playbackEventsListenIds: [String] = []
    fileprivate(set) var core: Core?
    static var hasAlreadyRegisteredPlaybacks = false
    fileprivate var viewController: AVPlayerViewController!
    private let baseObject = BaseObject()

    override open func viewDidLoad() {
        core?.parentView = view

        if isMediaControlEnabled != false {
            viewController = DecoratedPressAVPlayerViewController(player: self)
            core?.parentView = viewController?.contentOverlayView
            core?.parentController = self
            addChild(viewController)
            viewController.view.frame = view.bounds
            viewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            view.addSubview(viewController.view)
            viewController.didMove(toParent: self)
        }

        NotificationCenter.default.addObserver(self, selector: #selector(Player.willEnterForeground), name:
            UIApplication.willEnterForegroundNotification, object: nil)

        core?.render()
    }

    open var isMediaControlEnabled: Bool {
        return core?.options[kMediaControl] as? Bool ?? false
    }

    @objc fileprivate func willEnterForeground() {
        if let playback = activePlayback as? AVFoundationPlayback, !isMediaControlEnabled {
            Logger.logDebug("forced play after return from background", scope: "Player")
            playback.play()

    }

    private func setCore(with options: Options) {
        core = CoreFactory.create(with: options)
        bindCoreEvents()
    }
    
    private func bindCoreEvents() {
        core?.on(Event.willChangeActivePlayback.rawValue) { [weak self] _ in self?.unbindPlaybackEvents() }
        core?.on(Event.didChangeActivePlayback.rawValue) { [weak self] _ in self?.bindPlaybackEvents() }
        core?.on(Event.didEnterFullscreen.rawValue) { [weak self] (info: EventUserInfo) in self?.forward(.requestFullscreen, userInfo: info) }
        core?.on(Event.didExitFullscreen.rawValue) { [weak self] (info: EventUserInfo) in self?.forward(.exitFullscreen, userInfo: info) }

        core?.render()
    }

    open func load(_ source: String, mimeType: String? = nil) {
