import { ElementAttribute } from "../../ElementAttribute"; import { ElementType } from "../../ElementType"; import { OnMouseDown, OnTouchStart } from "../../EventListeners"; export class VideoAutoPlay { static applyOnDocument() { let startAutoPlayVideos = ()=> { ElementType.video.forEachInDoc( async ( v )=> { if ( ! ElementAttribute.autoplay.in( v ) ) { return; } if ( ! v.paused ) { return; } try { await v.play(); } catch ( e ) { } } ); OnMouseDown.remove( document.body, startAutoPlayVideos ); OnTouchStart.remove( document.body, startAutoPlayVideos ); }; OnMouseDown.add( document.body, startAutoPlayVideos ); OnTouchStart.add( document.body, startAutoPlayVideos ); } }