Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Video autoplay on Mobile Browser

I am using the following HTML5 and JQuery code to play a playlist of videos whose URLs are in an array URLArray[].

function NextFrag(){   if (index < URLArray.length)  {    $("#VideoContainer").html('<video  id="video1" controls autoplay width="95%"> "<source src= "'+ URLArray[index]+ '" type="video/mp4"></source> </video>' );    index++;    $("#video1").bind( "ended", NextFrag);  } } 

As we know that the autoplay feature of HTML5 is disabled in all mobile phones, as a result I have to play manually each video clip on mobile phone. which is definitely what I do not want.

I really want to know the alternative to this. I am really interested in code segment that I can include to make like autoplay without involving user to interact.

Is it possible to convert this to an android app to work. I am really in need to make it work like a play list, and I have no concern about how, I just need this functionality.

Please help.

like image 512
SotonJ Avatar asked Dec 10 '13 16:12

SotonJ


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.

Why is my video not Autoplaying HTML?

Chrome does not allow autoplay if the video is not muted. So to autoplay video you need to set both autoplay and muted attribute.

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.


2 Answers

Since the release of iOS 10 Apple has allowed muted video autoplay: https://webkit.org/blog/6784/new-video-policies-for-ios/

Chrome 53 on Android also allowing muted video autoplay: https://developers.google.com/web/updates/2016/07/autoplay

like image 116
Rihards Avatar answered Sep 23 '22 13:09

Rihards


UPDATE - January 2017: Since this answer is still getting me rep, I strongly encourage anyone reading this to check out the answer from Rihards and give it some love. Rihards' references are more modern than this answer and should help if you need auto-play in browser.


The auto play limitation in mobile browsers is an intentional limitation put in by the OS developers. To my knowledge, there is absolutely no way to auto play content in a mobile browser because the event that is required to trigger content play is an OS/Phone event, one which the browser itself has no control over or interaction with.

Facebook has implemented a video auto play feature to its advertising arsenal, but this is only through its native app. Even the mighty FB must surrender its will to the power of the phone gods.

I found one article about this new FB ad presentation technique that had some users in the comments section complaining about a way to disable autoplay in browsers like you can with the native FB app:

Facebook to Add Auto-Play Video to NewsFeed for All Mobile Users

But this is obviously a hypothetical complaint and banter because the comments were made prior to FB fully launching that feature.

My conclusion: If you absolutely need auto play, you are going to have to go "native" (ha... see what I did there?).

like image 42
Ryan McCoy Avatar answered Sep 22 '22 13:09

Ryan McCoy