+
+ // Proxy first play
+ const oldPlay = this.player.play.bind(this.player)
+ this.player.play = () => {
+ this.player.addClass('vjs-has-big-play-button-clicked')
+ this.player.play = oldPlay
+
+ this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime })
+ }
+ }
+
+ private runAutoQualityScheduler () {
+ this.autoQualityInterval = setInterval(() => {
+
+ // Not initialized or in HTTP fallback
+ if (this.torrent === undefined || this.torrent === null) return
+ if (this.isAutoResolutionOn() === false) return
+ if (this.isAutoResolutionObservation === true) return
+
+ const file = this.getAppropriateFile()
+ let changeResolution = false
+ let changeResolutionDelay = 0
+
+ // Lower resolution
+ if (this.isPlayerWaiting() && file.resolution.id < this.currentVideoFile.resolution.id) {
+ console.log('Downgrading automatically the resolution to: %s', file.resolution.label)
+ changeResolution = true
+ } else if (file.resolution.id > this.currentVideoFile.resolution.id) { // Higher resolution
+ console.log('Upgrading automatically the resolution to: %s', file.resolution.label)
+ changeResolution = true
+ changeResolutionDelay = this.CONSTANTS.AUTO_QUALITY_HIGHER_RESOLUTION_DELAY
+ }
+
+ if (changeResolution === true) {
+ this.updateResolution(file.resolution.id, changeResolutionDelay)
+
+ // Wait some seconds in observation of our new resolution
+ this.isAutoResolutionObservation = true
+
+ this.qualityObservationTimer = setTimeout(() => {
+ this.isAutoResolutionObservation = false
+ }, this.CONSTANTS.AUTO_QUALITY_OBSERVATION_TIME)
+ }
+ }, this.CONSTANTS.AUTO_QUALITY_SCHEDULER)
+ }
+
+ private isPlayerWaiting () {
+ return this.player && this.player.hasClass('vjs-waiting')