From 3bf0799f3108f7506ca4b99abfffaa3b76c88cf1 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sun, 8 Sep 2024 12:15:05 +0300 Subject: [PATCH] Code refactoring after #740 --- custom_components/webrtc/www/video-rtc.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/custom_components/webrtc/www/video-rtc.js b/custom_components/webrtc/www/video-rtc.js index 2e1a652..5341db7 100644 --- a/custom_components/webrtc/www/video-rtc.js +++ b/custom_components/webrtc/www/video-rtc.js @@ -163,14 +163,12 @@ export class VideoRTC extends HTMLElement { * https://developer.chrome.com/blog/autoplay/ */ play() { - this.video.play().catch((firstError) => { - console.warn(firstError); - const isAutoplayError = firstError.name == "NotAllowedError"; - + this.video.play().catch(er => { + const isAutoplayError = er.name === 'NotAllowedError'; if (!this.video.muted && isAutoplayError) { this.video.muted = true; - this.video.play().catch(secondError => { - console.warn(secondError); + this.video.play().catch(er => { + console.warn(er); }); } });