aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-videojs-plugin.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-20 10:21:28 +0200
committerChocobozzz <me@florianbigard.com>2018-04-20 10:21:28 +0200
commit3c40590d7467cfb187952993c4c7a5c4eaefb37a (patch)
treea7a23ee7cffe7008aba8c24e989078027987a5a9 /client/src/assets/player/peertube-videojs-plugin.ts
parent6cf57b443d559f54c80a36004670e38afadffee5 (diff)
downloadPeerTube-3c40590d7467cfb187952993c4c7a5c4eaefb37a.tar.gz
PeerTube-3c40590d7467cfb187952993c4c7a5c4eaefb37a.tar.zst
PeerTube-3c40590d7467cfb187952993c4c7a5c4eaefb37a.zip
Fix auto quality
Diffstat (limited to 'client/src/assets/player/peertube-videojs-plugin.ts')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts8
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