admin管理员组文章数量:1302274
I am using the HTML5 video tag on android and sometimes the chrome browser says it requires an explicit user gesture/click to start playback:
Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture
I know this is a known issue in Android but what I don't understand is why sometimes it plays automatically and on other occasions it requires a user action!
I am using the video tag with autoplay option.
I am using the HTML5 video tag on android and sometimes the chrome browser says it requires an explicit user gesture/click to start playback:
Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture
I know this is a known issue in Android but what I don't understand is why sometimes it plays automatically and on other occasions it requires a user action!
I am using the video tag with autoplay option.
Share Improve this question edited Dec 15, 2015 at 17:37 AHiggins 7,2277 gold badges38 silver badges55 bronze badges asked Dec 15, 2015 at 17:00 NoviceNovice 4111 gold badge6 silver badges14 bronze badges 1- Does this answer address your problem: stackoverflow./questions/32424775/… ? – craigts Commented Dec 28, 2015 at 18:21
2 Answers
Reset to default 5Auto-play is disabled since Android SDK 17 to avoid poor user experiences with video playback (i.e. undesired playback, undesired data usage). Normally video should only play following a user action. This is remended behavior for both Android and iOS nowadays.
You can, however, set setMediaPlaybackRequiresUserGesture to false to enable auto-play if you really need to. Remember to check the SDK version, because this option does not exist before Android SDK 17.
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 16) {
engine.getSettings().setMediaPlaybackRequiresUserGesture(false);
}
There is a LONG discussion and debate about Google's decision regarding autoplay here: http://chromium-bugs.chromium.narkive./cW5IXVgj/issue-178297-in-chromium-android-chrome-does-not-allow-applications-to-play-html5-audio-without-an
As of January 24th, 2017
HTML5 video tags can autoplay on android if the video is muted. You would need to include the muted and autoplay attributes in the tag to make it work as intended.
Here is a link to the article: Autoplay on Chrome for Android as of version 53
本文标签: javascriptUser gesture required to start playback in Android HTML5 playerStack Overflow
版权声明:本文标题:javascript - User gesture required to start playback in Android HTML5 player - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741668632a2391465.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论