1

I have to .mp4 videos. one is playing in safari with HTML 5 tag and other is not. Why?

<video loop autoplay muted >
        <source src="video.mp4" type="video/mp4"></source>            
        <source src="video.ogv" type="video/ogg; codecs=theora, vorbis"></source>
        <source src="video.webm" type="video/webm; codecs=vp8, vorbis"></source>
    </video>

1 Answers1

0
<script>
        var video = document.getElementById("video-bg");
        var refreshVideo,videoReady;
        video.play();
        refreshVideo = setInterval(function(){
            if ( video.readyState === 4 ) {
                videoReady = true;                      
                if (video.play){
                    stopFunc();
                }               
            }else{  
                videoReady = false;
            }
            if(videoReady == true){
                video.play();
            }
        },500)
        function stopFunc(){
            clearInterval(refreshVideo);
        }       
    </script>
  • Welcome to Stack Overflow! While this code may answer the question, it is better to include some context, explaining how it works and when to use it. Code-only answers tend to be less useful in the long run. See [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) for some more info. – Mark Ormesher Jan 10 '19 at 06:52