HTML 5 Autoplay Google Chrome Android Not Playing

风格不统一 提交于 2019-12-01 21:33:23

问题


I'm trying to play automatically a video when the user open the page on browser. On my laptop autoplay works on all browsers, but on android it doesn´t work on Google Chrome and in Iphone it doesn't works in safari. I already did a search and google chrome in android doesn't support html5 video tag so i used some javascript but it doesn't work too. Why? What should i do? Here's my code

<video id="video" autoplay autobuffer controls="controls" allowFullScreen >
<source src="video.mp4" type="video/mp4">
<source src="video.webm" type="video/webm" webView.mediaPlaybackRequiresUserAction = NO;>
<source src="video.theora.ogv" type="video/ogg">
<source src="video.flv" type="video/flv">
<source src="video.vob" type="video/vob">
<source src="video.mov" type="video/mov">
</video>    
<script type="text/javascript">
var video = document.getElementById('video');                           video.addEventListener('video',function(){
video.play();
});

                                video.addEventListener("domready", function(){                                              video.play();
});

                                video.addEventListener("ended", function(){ 
window.location = "http://www.google.com"
});
</script>

回答1:


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.

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



回答2:


I was also trying to autoplay videos on android chrome and found this:

On Android, html5 video autoplay attribute does not work

&num;1 klobag@chromium.org

Yes. It is as design. "autoplay" is disabled for Chrome for Android.

Apparently it's intentional.



来源:https://stackoverflow.com/questions/19543634/html-5-autoplay-google-chrome-android-not-playing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!