From 3c40590d7467cfb187952993c4c7a5c4eaefb37a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Apr 2018 10:21:28 +0200 Subject: Fix auto quality --- client/src/assets/player/peertube-videojs-plugin.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'client/src/assets/player/peertube-videojs-plugin.ts') diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 290d88724..a4f99559c 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts @@ -284,9 +284,11 @@ class PeerTubePlugin extends Plugin { private getAppropriateFile (averageDownloadSpeed?: number): VideoFile { if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined if (this.videoFiles.length === 1) return this.videoFiles[0] - if (this.torrent && this.torrent.progress === 1) return this.currentVideoFile - if (!averageDownloadSpeed) averageDownloadSpeed = this.getActualDownloadSpeed() + // Don't change the torrent is the play was ended + if (this.torrent && this.torrent.progress === 1 && this.player.ended()) return this.currentVideoFile + + if (!averageDownloadSpeed) averageDownloadSpeed = this.getAndSaveActualDownloadSpeed() // Filter videos we can play according to our bandwidth const filteredFiles = this.videoFiles.filter(f => { @@ -307,7 +309,7 @@ class PeerTubePlugin extends Plugin { return maxBy(filteredFiles, 'resolution.id') } - private getActualDownloadSpeed () { + private getAndSaveActualDownloadSpeed () { const start = Math.max(this.downloadSpeeds.length - this.CONSTANTS.BANDWIDTH_AVERAGE_NUMBER_OF_VALUES, 0) const lastDownloadSpeeds = this.downloadSpeeds.slice(start, this.downloadSpeeds.length) if (lastDownloadSpeeds.length === 0) return -1 -- cgit v1.2.3