Faster player ratio change on video update

pull/6266/head
Chocobozzz 2024-02-28 08:42:36 +01:00
parent dee2e66e02
commit 9808b179a5
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 9 additions and 1 deletions

View File

@ -225,11 +225,19 @@ class PeerTubePlugin extends Plugin {
const defaultRatio = getComputedStyle(this.player.el()).getPropertyValue(this.options.autoPlayerRatio.cssRatioVariable)
if (this.options.videoRatio()) {
const updateFromOptions = () => {
if (!this.options.videoRatio()) return
this.adaptPlayerFromRatio({ ratio: this.options.videoRatio(), defaultRatio })
}
updateFromOptions()
this.player.on('video-change', () => updateFromOptions())
this.player.on('video-ratio-changed', (_event, data: { ratio: number }) => {
if (this.options.videoRatio()) return
this.adaptPlayerFromRatio({ ratio: data.ratio, defaultRatio })
})
}