From a325db1776b956df8eb89fd7459dfcc97c89bb0e Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 7 Dec 2020 14:19:01 +0100 Subject: [PATCH] Revert "refactor(wt-plugin): create getVideoFile fn" This reverts commit 9110f52c4f1c0cf46fc906dbd4cef566497fb556. --- .../player/webtorrent/webtorrent-plugin.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts index 4eaaf51ec..287358ada 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts @@ -122,15 +122,8 @@ class WebTorrentPlugin extends Plugin { return this.currentVideoFile ? this.currentVideoFile.resolution.id : -1 } - private getVideoFile(): VideoFile { - const savedAverageBandwidth = getAverageBandwidthInStore() - return savedAverageBandwidth - ? this.getAppropriateFile(savedAverageBandwidth) - : this.pickAverageVideoFile() -} - updateVideoFile ( - videoFile: VideoFile, + videoFile?: VideoFile, options: { forcePlay?: boolean, seek?: number, @@ -138,6 +131,14 @@ class WebTorrentPlugin extends Plugin { } = {}, done: () => void = () => { /* empty */ } ) { + // Automatically choose the adapted video file + if (videoFile === undefined) { + const savedAverageBandwidth = getAverageBandwidthInStore() + videoFile = savedAverageBandwidth + ? this.getAppropriateFile(savedAverageBandwidth) + : this.pickAverageVideoFile() + } + if (videoFile === undefined) { throw Error(`Can't update video file since videoFile is undefined.`) } @@ -426,7 +427,7 @@ class WebTorrentPlugin extends Plugin { if (this.autoplay) { this.player.posterImage.hide() - return this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime }) + return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) } // Proxy first play @@ -435,7 +436,7 @@ class WebTorrentPlugin extends Plugin { this.player.addClass('vjs-has-big-play-button-clicked') this.player.play = oldPlay - this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime }) + this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) } } -- 2.41.0