From 4292161c17e6ba5ab775524d87e38827e82533ca Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 23 Dec 2023 21:34:52 +0100 Subject: [PATCH 1/2] fix: fix aspectRatio in MjpegstreamerAdaptive Signed-off-by: Stefan Dej --- .../webcams/streamers/Mjpegstreamer.vue | 11 +++--- .../streamers/MjpegstreamerAdaptive.vue | 37 ++++++++----------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/components/webcams/streamers/Mjpegstreamer.vue b/src/components/webcams/streamers/Mjpegstreamer.vue index 90c208a51..89f2a887c 100644 --- a/src/components/webcams/streamers/Mjpegstreamer.vue +++ b/src/components/webcams/streamers/Mjpegstreamer.vue @@ -133,7 +133,6 @@ export default class Mjpegstreamer extends Mixins(BaseMixin, WebcamMixin) { return reader?.read().then(({ done, value }) => { // If there is no more data to read if (done) { - window.console.log('done') controller.close() return } @@ -205,8 +204,8 @@ export default class Mjpegstreamer extends Mixins(BaseMixin, WebcamMixin) { this.startStream() } - @Watch('url') - urlChanged() { + @Watch('camSettings', { immediate: true, deep: true }) + camSettingsChanged() { this.aspectRatio = null this.restartStream() } @@ -236,9 +235,9 @@ export default class Mjpegstreamer extends Mixins(BaseMixin, WebcamMixin) { } onload() { - if (this.aspectRatio === null && this.$refs.image) { - this.aspectRatio = this.$refs.image.naturalWidth / this.$refs.image.naturalHeight - } + if (this.aspectRatio !== null || !this.$refs.image) return + + this.aspectRatio = this.$refs.image.naturalWidth / this.$refs.image.naturalHeight } } diff --git a/src/components/webcams/streamers/MjpegstreamerAdaptive.vue b/src/components/webcams/streamers/MjpegstreamerAdaptive.vue index fcd1399a8..bf59be8aa 100644 --- a/src/components/webcams/streamers/MjpegstreamerAdaptive.vue +++ b/src/components/webcams/streamers/MjpegstreamerAdaptive.vue @@ -1,15 +1,15 @@