Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

play a video in automatically way , when we load or refresh a dom

why when DOM that loeded or refreshed, the video that we set to autoplay and loop , will not played automatically untill we click on any tags that not set to any href ?

if this is an asynchronous process?
so i addded this JavaScript code for fix it , but that doesn’t work . the js codes :

const getVideo = async function () {
    const videoData = await fetch('./video/NEZAJA - Google Chrome 2024-03-05 12-46-49.mp4')
    const videoBlob = await videoData.blob()
    const videoURL = URL.createObjectURL(videoBlob)

    const noticeDivBott =  document.createElement('div')
    noticeDivBott.classList.add('notice-div-bott')
    noticeDivBott.innerHTML = 
    `
    <video class="video" style="border-radius: 30px;" autoplay loop width="380px">
    <source src='${videoURL}'  type="video/mp4" />
    Download the
    <a href="/media/cc0-videos/flower.webm">WEBM</a>
    or
    <a href="/media/cc0-videos/flower.mp4">MP4</a>
    video.
    </video>
    `
    return notice.appendChild(noticeDivBott)

}

getVideo()

I expect the video that i added in my project , play automatically immediately after i load the dom or refresh that .

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Videos with autoplay, has to be muted, so insert an "muted" inside the video tag

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading