Android webview html5 video autoplay not working on android 4.0.3

后端 未结 4 1748
滥情空心
滥情空心 2020-12-08 23:50

I have developed an application where the user can set videos on a web page: - They can specify a Youtube URL OR - They can upload a video

Depending on which option

相关标签:
4条回答
  • 2020-12-09 00:17

    [upgraded to answer per request]

    Autoplay on most mobile platforms (Android, iOS) gets blocked to avoid poor user experiences - video should only play following a user action. You can usually work around it by triggering the play() on another event (eg the onloaded event)

    0 讨论(0)
  • 2020-12-09 00:21

    Auto-play is disabled since Android SDK 17, but you can set setMediaPlaybackRequiresUserGesture to false to re-enable auto-play. Don't forget to check the SDK version because there is not such function in earlier versions.

        int SDK_INT = android.os.Build.VERSION.SDK_INT;
        if (SDK_INT > 16) {
            engine.getSettings().setMediaPlaybackRequiresUserGesture(false);
        }
    
    0 讨论(0)
  • 2020-12-09 00:27

    For Android 4.0.x, try triggering the event : loadstart

    var vid=document.getElementById('video');
    vid.addEventListener("loadstart", showVideo, false);
    function showVideo(e) {
      vid.play();
    }
    
    0 讨论(0)
  • 2020-12-09 00:41

    That can not be achieved, autoplay on most mobile platforms (Android, iOS) gets blocked to avoid poor user experiences. Look at this: http://www.longtailvideo.com/html5/autoloop/

    0 讨论(0)
提交回复
热议问题