8

I'm using mediaelement.js to display a video. I'm using this code:

<body>
<video id="player1" style="width: 100%; height: 100%;" preload="auto" autoplay="true" src="video.mp4"/>

<script>
    $('video').mediaelementplayer({
        features: ['playpause', 'progress', 'current', 'duration', 'tracks', 'volume', 'fullscreen'],
    });

    var player = new MediaElementPlayer('player1');
    player.play();
</script>
</body>

When the page loads, I'd like to automatically start the video. This works fine in desktop browsers, however, in mobile browsers the video doesn't automatically play.

What am I doing wrong?

3rdthemagical
  • 5,271
  • 18
  • 36
Bv202
  • 3,924
  • 13
  • 46
  • 80
  • you now need a user-initialized event to play() media on mobile. you can use a clear div to trick the user into touching it to chain up a click() event into a play() call, but can't play() without the user touching _something_ – dandavis Aug 08 '16 at 21:02

1 Answers1

-1

Just put autoplay muted like this:

<video id="video" class="video" autoplay muted />

It will activate autoplay for every video.

adiga
  • 34,372
  • 9
  • 61
  • 83
AJI
  • 1