diff options
-rw-r--r-- | client/src/assets/player/webtorrent/webtorrent-plugin.ts | 21 |
1 files 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 { | |||
122 | return this.currentVideoFile ? this.currentVideoFile.resolution.id : -1 | 122 | return this.currentVideoFile ? this.currentVideoFile.resolution.id : -1 |
123 | } | 123 | } |
124 | 124 | ||
125 | private getVideoFile(): VideoFile { | ||
126 | const savedAverageBandwidth = getAverageBandwidthInStore() | ||
127 | return savedAverageBandwidth | ||
128 | ? this.getAppropriateFile(savedAverageBandwidth) | ||
129 | : this.pickAverageVideoFile() | ||
130 | } | ||
131 | |||
132 | updateVideoFile ( | 125 | updateVideoFile ( |
133 | videoFile: VideoFile, | 126 | videoFile?: VideoFile, |
134 | options: { | 127 | options: { |
135 | forcePlay?: boolean, | 128 | forcePlay?: boolean, |
136 | seek?: number, | 129 | seek?: number, |
@@ -138,6 +131,14 @@ class WebTorrentPlugin extends Plugin { | |||
138 | } = {}, | 131 | } = {}, |
139 | done: () => void = () => { /* empty */ } | 132 | done: () => void = () => { /* empty */ } |
140 | ) { | 133 | ) { |
134 | // Automatically choose the adapted video file | ||
135 | if (videoFile === undefined) { | ||
136 | const savedAverageBandwidth = getAverageBandwidthInStore() | ||
137 | videoFile = savedAverageBandwidth | ||
138 | ? this.getAppropriateFile(savedAverageBandwidth) | ||
139 | : this.pickAverageVideoFile() | ||
140 | } | ||
141 | |||
141 | if (videoFile === undefined) { | 142 | if (videoFile === undefined) { |
142 | throw Error(`Can't update video file since videoFile is undefined.`) | 143 | throw Error(`Can't update video file since videoFile is undefined.`) |
143 | } | 144 | } |
@@ -426,7 +427,7 @@ class WebTorrentPlugin extends Plugin { | |||
426 | if (this.autoplay) { | 427 | if (this.autoplay) { |
427 | this.player.posterImage.hide() | 428 | this.player.posterImage.hide() |
428 | 429 | ||
429 | return this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime }) | 430 | return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) |
430 | } | 431 | } |
431 | 432 | ||
432 | // Proxy first play | 433 | // Proxy first play |
@@ -435,7 +436,7 @@ class WebTorrentPlugin extends Plugin { | |||
435 | this.player.addClass('vjs-has-big-play-button-clicked') | 436 | this.player.addClass('vjs-has-big-play-button-clicked') |
436 | this.player.play = oldPlay | 437 | this.player.play = oldPlay |
437 | 438 | ||
438 | this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime }) | 439 | this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) |
439 | } | 440 | } |
440 | } | 441 | } |
441 | 442 | ||