diff options
Diffstat (limited to 'client/src/assets/player/shared/peertube/peertube-plugin.ts')
-rw-r--r-- | client/src/assets/player/shared/peertube/peertube-plugin.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index cf866723c..7aeae2670 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts | |||
@@ -115,6 +115,8 @@ class PeerTubePlugin extends Plugin { | |||
115 | this.hideFatalError() | 115 | this.hideFatalError() |
116 | }) | 116 | }) |
117 | }) | 117 | }) |
118 | |||
119 | this.initOnRatioChange() | ||
118 | } | 120 | } |
119 | 121 | ||
120 | dispose () { | 122 | dispose () { |
@@ -210,6 +212,25 @@ class PeerTubePlugin extends Plugin { | |||
210 | this.runUserViewing() | 212 | this.runUserViewing() |
211 | } | 213 | } |
212 | 214 | ||
215 | private initOnRatioChange () { | ||
216 | if (!this.options.autoPlayerRatio) return | ||
217 | |||
218 | const defaultRatio = getComputedStyle(this.player.el()).getPropertyValue(this.options.autoPlayerRatio.cssRatioVariable) | ||
219 | |||
220 | this.player.on('video-ratio-changed', (_event, data: { ratio: number }) => { | ||
221 | const el = this.player.el() as HTMLElement | ||
222 | |||
223 | // In portrait screen mode, we allow player with bigger height size than width | ||
224 | const portraitMode = getComputedStyle(el).getPropertyValue(this.options.autoPlayerRatio.cssPlayerPortraitModeVariable) === '1' | ||
225 | |||
226 | const currentRatio = !portraitMode && data.ratio < 1 | ||
227 | ? defaultRatio | ||
228 | : data.ratio | ||
229 | |||
230 | el.style.setProperty('--player-ratio', currentRatio + '') | ||
231 | }) | ||
232 | } | ||
233 | |||
213 | // --------------------------------------------------------------------------- | 234 | // --------------------------------------------------------------------------- |
214 | 235 | ||
215 | private runUserViewing () { | 236 | private runUserViewing () { |