Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 autoplay video in Mobile device

Tags:

html

Auto play is not working without muted attribute, when I try to open url in mobile device. How to play video without using muted attribute ? I need to volume without click on muted button and one more important thing is that all thing will be working without JS and Jquery. enter image description here

like image 648
Sawan mishra Avatar asked Feb 10 '17 13:02

Sawan mishra


People also ask

How do I autoplay a video in HTML mobile?

Muted autoplay for video is supported by Chrome for Android as of version 53. Playback will start automatically for a video element once it comes into view if both autoplay and muted are set, and playback of muted videos can be initiated progamatically with play().

Can you autoplay video on mobile?

Mobile device settings can block autoplay Most mobile devices, including Apple iPhones, Apple iPads and many Android and Microsoft devices do not support the video autoplay feature so your video will not play automatically if a visitor is on one of these devices.

Can I autoplay a video with sound HTML5?

Muted autoplay is always allowed. Autoplay with sound is allowed if: User has interacted with the domain (click, tap, etc.). On desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously played video with sound.

How do I enable video autoplay in HTML?

The autoplay attribute is a boolean attribute. When present, the video will automatically start playing. Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.


2 Answers

You wont be able to achieve this in iOS without hacks. From the official Apple WebKit documentation:

Starting in iOS 10, WebKit relaxes its inline and autoplay policies to make these presentations possible, but still keeps in mind sites’ bandwidth and users’ batteries.

By default, WebKit will have the following policies:

  • video elements will be allowed to autoplay without a user gesture if their source media contains no audio tracks.
  • video muted elements will also be allowed to autoplay without a user gesture. If a element gains an audio track or becomes un-muted without a user gesture, playback will pause.

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

As for Mobile Chrome (Android):

Muted autoplay for video is supported by Chrome for Android as of version 53. Playback will start automatically for a video element once it comes into view if both autoplay and muted are set, and playback of muted videos can be initiated progamatically with play(). Previously, playback on mobile had to be initiated by a user gesture, regardless of the muted state.

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

like image 176
Dan H Avatar answered Sep 21 '22 01:09

Dan H


<video autoplay="autoplay" loop="loop" muted defaultMuted playsinline  oncontextmenu="return false;"  preload="auto"  id="myVideo">
        <source src="assets/video/1.mp4" type="video/mp4">
        </video>

This code worked for me on Ios and Android phone

like image 23
Tugrul Yildirim Avatar answered Sep 17 '22 01:09

Tugrul Yildirim