Fix html video autoplay in some cases

This commit is contained in:
Alexey Khit
2023-07-08 09:30:32 +03:00
parent 39cc4610e3
commit ce61d5759c
+5 -3
View File
@@ -157,10 +157,12 @@ export class VideoRTC extends HTMLElement {
* https://developer.chrome.com/blog/autoplay/
*/
play() {
this.video.play().catch(er => {
if (er.name === "NotAllowedError" && !this.video.muted) {
this.video.play().catch(() => {
if (!this.video.muted) {
this.video.muted = true;
this.video.play().catch(() => console.debug);
this.video.play().catch(er => {
console.warn(er);
});
}
});
}