fix: don't createObjectURL, when webcam img doesn't exist in Mjpegstreamer.vue (#834)

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej 2022-05-21 18:10:54 +02:00 committed by GitHub
parent cc888a3924
commit fd89ff7ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,8 +148,12 @@ export default class Mjpegstreamer extends Mixins(BaseMixin) {
}
// we're done reading the jpeg. Time to render it.
else {
img.src = URL.createObjectURL(new Blob([imageBuffer], { type: TYPE_JPEG }))
img.onload = () => URL.revokeObjectURL(img.src)
if (img) {
img.src = URL.createObjectURL(
new Blob([imageBuffer], { type: TYPE_JPEG })
)
img.onload = () => URL.revokeObjectURL(img.src)
}
frames++
contentLength = 0
bytesRead = 0