From 89ac282e0437ae839e3d71566f25321f9b9384e9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Sep 2021 15:43:15 +0200 Subject: Fix embed api --- .../assets/player/webtorrent/webtorrent-plugin.ts | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'client/src/assets/player/webtorrent') diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts index a464f02d5..1a1cd7f1a 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts @@ -178,7 +178,7 @@ class WebTorrentPlugin extends Plugin { this.selectAppropriateResolution(true) } - updateResolution (resolutionId: number, delay = 0) { + updateEngineResolution (resolutionId: number, delay = 0) { // Remember player state const currentTime = this.player.currentTime() const isPaused = this.player.paused() @@ -236,6 +236,22 @@ class WebTorrentPlugin extends Plugin { return this.currentVideoFile } + changeQuality (id: number) { + if (id === -1) { + if (this.autoResolutionPossible === true) { + this.autoResolution = true + + this.selectAppropriateResolution(false) + } + + return + } + + this.autoResolution = false + this.updateEngineResolution(id) + this.selectAppropriateResolution(false) + } + private addTorrent ( magnetOrTorrentUrl: string, previousVideoFile: VideoFile, @@ -458,7 +474,7 @@ class WebTorrentPlugin extends Plugin { } if (changeResolution === true) { - this.updateResolution(file.resolution.id, changeResolutionDelay) + this.updateEngineResolution(file.resolution.id, changeResolutionDelay) // Wait some seconds in observation of our new resolution this.isAutoResolutionObservation = true @@ -598,14 +614,14 @@ class WebTorrentPlugin extends Plugin { label: this.buildQualityLabel(file), height: file.resolution.id, selected: false, - selectCallback: () => this.qualitySwitchCallback(file.resolution.id) + selectCallback: () => this.changeQuality(file.resolution.id) })) resolutions.push({ id: -1, label: this.player.localize('Auto'), selected: true, - selectCallback: () => this.qualitySwitchCallback(-1) + selectCallback: () => this.changeQuality(-1) }) this.player.peertubeResolutions().add(resolutions) @@ -621,22 +637,6 @@ class WebTorrentPlugin extends Plugin { return label } - private qualitySwitchCallback (id: number) { - if (id === -1) { - if (this.autoResolutionPossible === true) { - this.autoResolution = true - - this.selectAppropriateResolution(false) - } - - return - } - - this.autoResolution = false - this.updateResolution(id) - this.selectAppropriateResolution(false) - } - private selectAppropriateResolution (byEngine: boolean) { const resolution = this.autoResolution ? -1 -- cgit v1.2.3