I have a 5MB filesize 40-second long video that is needed to display with audio and controls available.
What I have right now works 95% of the time's page load but sometimes when I or clients visit the website the video randomly stops playing immediately after pressing the play button (it's either a black screen and you cannot even start the video anymore or it's just looping: play, immediate stop, then hitting play results in the same stop on repeat just to hit the play button again ((i believe it happens not even 1-second passing after hitting play button)) which happens until you refresh the page), then if you press play again - same thing repeats.
I tried multiple solutions, my latest code on this:
<video controls=""><source src="" type="video/mp4" /></video> <script> $(document).ready(function () { let video = $("video"); video.onerror = () => { console.error(`Error ${video.error.code}; details: ${video.error.message}`); } // play the video as soon as the first frames are cached video.oncanplay = () => { video.play(); }; // or play when the entire video is cached video.oncanplaythrough = () => { video.play(); }; }); </script> 4Related questions 35 play pause html5 video javascript 14 html5 play event vs playing event in video tag 0 Cuepoints play button not playing video on second click Related questions 35 play pause html5 video javascript 14 html5 play event vs playing event in video tag 0 Cuepoints play button not playing video on second click 1 play html5 video inside iframe from play button in parent 0 HTML5 Video Play/Pause issue 12 Need to show HTML5 Video Controls on Hover or Play 1 HTML5 Video Locks Up / Stops Playing After ~100 Seconds 1 Add event on html5 video play button 0 How to stop autoplay video on button click and then start playing again on button click using js 0 HTML5 play pause video on image or video click Load 7 more related questions Show fewer related questions
Reset to default