Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions agentweb-core/src/main/java/com/just/agentweb/AbsAgentWebSettings.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ private void settings(WebView webView) {
mWebSettings.setSupportZoom(true);
mWebSettings.setBuiltInZoomControls(false);
mWebSettings.setSavePassword(false);
// Issue #339: HTMLMediaElement.play() throws "API can only be initiated by
// a user gesture" for embedded video players that auto-play. Allow
// programmatic playback so embedded players (e.g. share-page videos) work.
mWebSettings.setMediaPlaybackRequiresUserGesture(false);
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebSettings#setMediaPlaybackRequiresUserGesture was added in API 17, but this library’s minSdkVersion is 14 (agentweb-core/build.gradle:9). Calling it unconditionally here can crash on API 14–16 (NoSuchMethodError/verification failure). Guard the call with if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) (or use reflection) so pre-17 devices don’t break.

Suggested change
mWebSettings.setMediaPlaybackRequiresUserGesture(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mWebSettings.setMediaPlaybackRequiresUserGesture(false);
}

Copilot uses AI. Check for mistakes.
if (AgentWebUtils.checkNetwork(webView.getContext().getApplicationContext())) {
//根据cache-control获取数据。
mWebSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
Expand Down
Loading