Skip to content

Commit

Permalink
Code refactoring after #740
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Sep 8, 2024
1 parent 2aef88b commit 3bf0799
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions custom_components/webrtc/www/video-rtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
});
Expand Down

0 comments on commit 3bf0799

Please sign in to comment.