diff options
Diffstat (limited to 'client/src/assets/player')
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 8 |
1 files changed, 5 insertions, 3 deletions
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 { | |||
284 | private getAppropriateFile (averageDownloadSpeed?: number): VideoFile { | 284 | private getAppropriateFile (averageDownloadSpeed?: number): VideoFile { |
285 | if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined | 285 | if (this.videoFiles === undefined || this.videoFiles.length === 0) return undefined |
286 | if (this.videoFiles.length === 1) return this.videoFiles[0] | 286 | if (this.videoFiles.length === 1) return this.videoFiles[0] |
287 | if (this.torrent && this.torrent.progress === 1) return this.currentVideoFile | ||
288 | 287 | ||
289 | if (!averageDownloadSpeed) averageDownloadSpeed = this.getActualDownloadSpeed() | 288 | // Don't change the torrent is the play was ended |
289 | if (this.torrent && this.torrent.progress === 1 && this.player.ended()) return this.currentVideoFile | ||
290 | |||
291 | if (!averageDownloadSpeed) averageDownloadSpeed = this.getAndSaveActualDownloadSpeed() | ||
290 | 292 | ||
291 | // Filter videos we can play according to our bandwidth | 293 | // Filter videos we can play according to our bandwidth |
292 | const filteredFiles = this.videoFiles.filter(f => { | 294 | const filteredFiles = this.videoFiles.filter(f => { |
@@ -307,7 +309,7 @@ class PeerTubePlugin extends Plugin { | |||
307 | return maxBy(filteredFiles, 'resolution.id') | 309 | return maxBy(filteredFiles, 'resolution.id') |
308 | } | 310 | } |
309 | 311 | ||
310 | private getActualDownloadSpeed () { | 312 | private getAndSaveActualDownloadSpeed () { |
311 | const start = Math.max(this.downloadSpeeds.length - this.CONSTANTS.BANDWIDTH_AVERAGE_NUMBER_OF_VALUES, 0) | 313 | const start = Math.max(this.downloadSpeeds.length - this.CONSTANTS.BANDWIDTH_AVERAGE_NUMBER_OF_VALUES, 0) |
312 | const lastDownloadSpeeds = this.downloadSpeeds.slice(start, this.downloadSpeeds.length) | 314 | const lastDownloadSpeeds = this.downloadSpeeds.slice(start, this.downloadSpeeds.length) |
313 | if (lastDownloadSpeeds.length === 0) return -1 | 315 | if (lastDownloadSpeeds.length === 0) return -1 |