From 8eb8bc201e0861599702a4048ff7edc59ad34d89 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Jun 2018 17:51:25 +0200 Subject: Pick average video file insead of max quality --- client/src/assets/player/peertube-videojs-plugin.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index b54f096b2..e68d79e40 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts @@ -147,7 +147,7 @@ class PeerTubePlugin extends Plugin { const savedAverageBandwidth = getAverageBandwidth() videoFile = savedAverageBandwidth ? this.getAppropriateFile(savedAverageBandwidth) - : this.videoFiles[0] + : this.pickAverageVideoFile() } // Don't add the same video file once again @@ -377,7 +377,7 @@ class PeerTubePlugin extends Plugin { } else { // Don't try on iOS that does not support MediaSource if (this.isIOS()) { - this.currentVideoFile = this.videoFiles[0] + this.currentVideoFile = this.pickAverageVideoFile() return this.fallbackToHttp(undefined, false) } @@ -533,6 +533,12 @@ class PeerTubePlugin extends Plugin { settingsDialog.on('mouseleave', () => enableInactivity()) } + private pickAverageVideoFile () { + if (this.videoFiles.length === 1) return this.videoFiles[0] + + return this.videoFiles[Math.floor(this.videoFiles.length / 2)] + } + // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657 private initSmoothProgressBar () { const SeekBar = videojsUntyped.getComponent('SeekBar') -- cgit v1.2.3