     }
     
     private func bindPlaybackEvents() {
-        guard let playback = core?.activePlayback else { return }
+        guard let playback = playback else { return }
         listenToOnce(playback, eventName: Event.bufferUpdate.rawValue) { [weak self] (_: EventUserInfo) in self?.triggerDvrEvent() }
     }
     

        super.init(context: context)
        bindEvents()
    }
}


//MARK: Events Binding
extension DVRPlugin {
    fileprivate func bindEvents() {
        stopListening()
        
        bindCoreEvents()

        listenTo(container, eventName: InternalEvent.didChangePlayback.rawValue) { [weak self] (_: EventUserInfo) in self?.bindEvents() }
    }
    
    func triggerDvrEvent() {
        guard let duration = duration else { return }
        let userInfo = ["dvrEnabled": dvrEnabled,
                        "duration": duration] as [String : Any]
        playback?.trigger(InternalEvent.detectDVR.rawValue, userInfo: userInfo)
    }
}

//MARK: DVR
extension DVRPlugin {
    var minDvrSize: Double {
        return 60
    }
    
    var duration: Double? {
        guard let currentTime = playback?.player?.currentTime() else { return nil }
        return CMTimeGetSeconds(currentTime)
    }
    
    private var dvrEnabled: Bool {
        guard let player = playback?.player else { return false }
        return playback?.playbackType == .live && CMTimeGetSeconds(player.currentTime()) >= minDvrSize
    }
}
