I'm working on a HTML5 video player automation(test page is a html page). I tried to call myPlayer.Play()
through Javascript. On Android, however, I got this error:
Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.
after sending a Play()
request.
I know autoplay
is disabled on lots of devices on purpose to save users bandwidth. But the first time Play()
seems also needed the user gesture. What is the workaround for this so that I can automate testing for the player device?
You can disable this security function. For example:
WebView mWebView = (WebView) findViewById(R.id.web_view); mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
Available in API versions 17 and above
More info see this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With