简体   繁体   中英

HTML5 Video autoplay in Android

I am developing an html5 player supports ads with video-js

Since i know it doesn't work in iOS, is it the same on Android?

So far i've tried these with no luck on autoplay in Android

HTML

  <video id="inReadPlayer" autoplay loop="loop" 
    controls preload="auto" class="video-js vjs-default-skin" width="640"
height="360" > <source src="'+videoSource+'" type="video/mp4">
  </video>

JS

 var player = videojs('inReadPlayer', { /* Options */ }, function() {
            this.play();
            this.on('ended', function() {

            });
 });

Thanks in advance

Try this:

 var videoplayer = document.getElementById('inReadPlayer') videoplayer.addEventListener("load", function() { videoplayer.play(); }); videoplayer.onended = function() { source.setAttribute('src', 'MAINVIDEO.mp4'); }; 
  <video id="inReadPlayer" autoplay loop="loop" controls preload="auto" class="video-js vjs-default-skin" width="640" height="360" > <source src="'+videoSource+'" type="video/mp4"> </video> 

Note that this snippet won't work because there is no video source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM