Skip to content

Commit 0e5b160

Browse files
Teng-Hui ZhuAndroid (Google) Code Review
authored andcommitted
add a webview API to support media play without user gesture
bug:6806306 webkit change: https://android-git.corp.google.com/g/#/c/208568/ Change-Id: Ic70e5d3f152a7e8d8fdfa1d6f89f96c8cd3c7075
1 parent 495b56c commit 0e5b160

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

api/current.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26615,6 +26615,7 @@ package android.webkit {
2661526615
method public boolean getLightTouchEnabled();
2661626616
method public boolean getLoadWithOverviewMode();
2661726617
method public synchronized boolean getLoadsImagesAutomatically();
26618+
method public boolean getMediaPlaybackRequiresUserGesture();
2661826619
method public synchronized int getMinimumFontSize();
2661926620
method public synchronized int getMinimumLogicalFontSize();
2662026621
method public deprecated boolean getNavDump();
@@ -26664,6 +26665,7 @@ package android.webkit {
2666426665
method public void setLightTouchEnabled(boolean);
2666526666
method public void setLoadWithOverviewMode(boolean);
2666626667
method public synchronized void setLoadsImagesAutomatically(boolean);
26668+
method public void setMediaPlaybackRequiresUserGesture(boolean);
2666726669
method public synchronized void setMinimumFontSize(int);
2666826670
method public synchronized void setMinimumLogicalFontSize(int);
2666926671
method public deprecated void setNavDump(boolean);

core/java/android/webkit/WebSettings.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,26 @@ public boolean supportZoom() {
198198
throw new MustOverrideException();
199199
}
200200

201+
/**
202+
* Sets whether the WebView requires a user gesture to play media.
203+
* The default is true.
204+
*
205+
* @param require whether the WebView requires a user gesture to play media
206+
*/
207+
public void setMediaPlaybackRequiresUserGesture(boolean require) {
208+
throw new MustOverrideException();
209+
}
210+
211+
/**
212+
* Gets whether the WebView requires a user gesture to play media.
213+
*
214+
* @return true if the WebView requires a user gesture to play media
215+
* @see #setMediaPlaybackRequiresUserGesture
216+
*/
217+
public boolean getMediaPlaybackRequiresUserGesture() {
218+
throw new MustOverrideException();
219+
}
220+
201221
/**
202222
* Sets whether the WebView should use its built-in zoom mechanisms. The
203223
* built-in zoom mechanisms comprise on-screen zoom controls, which are

core/java/android/webkit/WebSettingsClassic.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class WebSettingsClassic extends WebSettings {
116116
private boolean mNeedInitialFocus = true;
117117
private boolean mNavDump = false;
118118
private boolean mSupportZoom = true;
119+
private boolean mMediaPlaybackRequiresUserGesture = true;
119120
private boolean mBuiltInZoomControls = false;
120121
private boolean mDisplayZoomControls = true;
121122
private boolean mAllowFileAccess = true;
@@ -458,6 +459,25 @@ public boolean supportZoom() {
458459
return mSupportZoom;
459460
}
460461

462+
/**
463+
* @see android.webkit.WebSettings#setMediaPlaybackRequiresUserGesture(boolean)
464+
*/
465+
@Override
466+
public void setMediaPlaybackRequiresUserGesture(boolean support) {
467+
if (mMediaPlaybackRequiresUserGesture != support) {
468+
mMediaPlaybackRequiresUserGesture = support;
469+
postSync();
470+
}
471+
}
472+
473+
/**
474+
* @see android.webkit.WebSettings#getMediaPlaybackRequiresUserGesture()
475+
*/
476+
@Override
477+
public boolean getMediaPlaybackRequiresUserGesture() {
478+
return mMediaPlaybackRequiresUserGesture;
479+
}
480+
461481
/**
462482
* @see android.webkit.WebSettings#setBuiltInZoomControls(boolean)
463483
*/

0 commit comments

Comments
 (0)