diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2020-12-07 14:19:01 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-07 16:52:35 +0100 |
commit | a325db1776b956df8eb89fd7459dfcc97c89bb0e (patch) | |
tree | 90e899c2def7a97c30a816bd8ad0b7bff59cb851 /client/src/assets/player/webtorrent | |
parent | 8426a71144108b645f26f1ad663e066444b38ceb (diff) | |
download | PeerTube-a325db1776b956df8eb89fd7459dfcc97c89bb0e.tar.gz PeerTube-a325db1776b956df8eb89fd7459dfcc97c89bb0e.tar.zst PeerTube-a325db1776b956df8eb89fd7459dfcc97c89bb0e.zip |
Revert "refactor(wt-plugin): create getVideoFile fn"
This reverts commit 9110f52c4f1c0cf46fc906dbd4cef566497fb556.
Diffstat (limited to 'client/src/assets/player/webtorrent')
-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 | ||