Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video.js - Autoplay and Loop not working on phone

I use this code to make a video (eg. banner, so no controls) autoplay and loop forever.

<video id="video1" class="video-js vjs-default-skin"
      controls width="900" height="500"
      poster="myposter.jpg"
      data-setup='{
        "controls": false,
        "loop": "true",
        "autoplay": true, 
        "preload": "true"}'>
         <source src="thisismyvideoyay.webm" type='video/webm' />
    </video>

It works fine on my computer but on my phone (Android OS 4.2.2 with Chrome) it's not autoplaying or preloading and not looping after it finished.

I read this on Video.js page:

Auto: Start loading the video immediately (if the browser agrees). Some mobile devices like iPhones and iPads will not preload the video in order to protect their users' bandwidth. This is why the value is called 'auto' and not something more final like 'true'.

I set the preload to true but it still doesn't autoplay or loop.

Is that a feature of my browser and how can I avoid that?

I tried on other browsers:

  • UC Browser doesn't seem to support HTML5 at all?
  • Stock browser shows a little video icon but doesn't show the player, too
  • ↑ Same with Maxthon ↑
like image 614
Lesik2008 Avatar asked Jul 08 '13 22:07

Lesik2008


1 Answers

On mobile, you can autoplay if you put muted option

<video autoplay muted>
  <source src="video.webm" type="video/webm" />
  <source src="video.mp4" type="video/mp4" />
</video>

Chrome v53: https://developers.google.com/web/updates/2016/07/autoplay

iOS 10 : https://webkit.org/blog/6784/new-video-policies-for-ios

like image 198
srgbnd Avatar answered Sep 21 '22 11:09

srgbnd