web404
web404

Reputation: 33

Preroll Html5 autoplay Video

I have problem with html5 player.

<video id="videoPlayer" src="ads-video.mp4"   width="604" height="340" autobuffer controls />

    <script type="text/javascript"> 
    var nextVideo = "video-video.mp4" ;
    var videoPlayer = document.getElementById('videoPlayer');
    videoPlayer.addEventListener('ended', function(){
            videoPlayer.src = nextVideo;

            }, false);

    </script>

when video add is ended i want that video-video start automatically , who can i do this ?

Upvotes: 1

Views: 746

Answers (1)

aldel
aldel

Reputation: 6748

That code should work if you just put the autoplay attribute in the video tag. If you don't want it to autoplay the ads, you can set videoPlayer.autoplay = true in the event listener.

Upvotes: 1

Related Questions