aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/assets/player/webtorrent/webtorrent-plugin.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
index 287358ada..4eaaf51ec 100644
--- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts
+++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
@@ -122,8 +122,15 @@ 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
125 updateVideoFile ( 132 updateVideoFile (
126 videoFile?: VideoFile, 133 videoFile: VideoFile,
127 options: { 134 options: {
128 forcePlay?: boolean, 135 forcePlay?: boolean,
129 seek?: number, 136 seek?: number,
@@ -131,14 +138,6 @@ class WebTorrentPlugin extends Plugin {
131 } = {}, 138 } = {},
132 done: () => void = () => { /* empty */ } 139 done: () => void = () => { /* empty */ }
133 ) { 140 ) {
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
142 if (videoFile === undefined) { 141 if (videoFile === undefined) {
143 throw Error(`Can't update video file since videoFile is undefined.`) 142 throw Error(`Can't update video file since videoFile is undefined.`)
144 } 143 }
@@ -427,7 +426,7 @@ class WebTorrentPlugin extends Plugin {
427 if (this.autoplay) { 426 if (this.autoplay) {
428 this.player.posterImage.hide() 427 this.player.posterImage.hide()
429 428
430 return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) 429 return this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime })
431 } 430 }
432 431
433 // Proxy first play 432 // Proxy first play
@@ -436,7 +435,7 @@ class WebTorrentPlugin extends Plugin {
436 this.player.addClass('vjs-has-big-play-button-clicked') 435 this.player.addClass('vjs-has-big-play-button-clicked')
437 this.player.play = oldPlay 436 this.player.play = oldPlay
438 437
439 this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) 438 this.updateVideoFile(this.getVideoFile(), { forcePlay: true, seek: this.startTime })
440 } 439 }
441 } 440 }
442 441