From 140c7ce1b15412dee40e9a433e28a0ea14ce9023 Mon Sep 17 00:00:00 2001 From: Jack Cheung Date: Thu, 30 Jun 2016 10:22:24 +0800 Subject: [PATCH] 1. updated: support SoundCloud playback Signed-off-by: Jack Cheung --- .../src/main/java/com/hkm/ezwebview/Util/Fx9C.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/src/main/java/com/hkm/ezwebview/Util/Fx9C.java b/library/src/main/java/com/hkm/ezwebview/Util/Fx9C.java index edb39b1..2b9281a 100644 --- a/library/src/main/java/com/hkm/ezwebview/Util/Fx9C.java +++ b/library/src/main/java/com/hkm/ezwebview/Util/Fx9C.java @@ -573,6 +573,7 @@ private static boolean hideSlider(final Object view) { protected final String DEFAULT_ENCODING = "UTF-8"; protected Context context; + protected boolean allowAutomaticMediaPlayback = false; protected boolean allowHTTPSMixedContent = false; protected long animateDuration; protected String baseUrl = ""; @@ -606,6 +607,16 @@ private Fx9C(Context context) { animateDuration = 500; /* default duration value for webview visibility transition animation */ } + /** + * Allow automatic media playback without user gesture + * required for SoundCloud to work properly + * @param allow + */ + public Fx9C setAllowAutomaticMediaPlayback(boolean allow) { + allowAutomaticMediaPlayback = allow; + return this; + } + public Fx9C setAllowHTTPSMixedContent(boolean allow) { allowHTTPSMixedContent = allow; return this; @@ -726,6 +737,7 @@ public void loadUrl(String url) throws Exception { webView.setWebViewClient(webViewClient); } webView.getSettings().setJavaScriptEnabled(isJavaScriptEnabled); + webView.getSettings().setMediaPlaybackRequiresUserGesture(!allowAutomaticMediaPlayback); updateWebChromeClient(); updateWebViewCacheMode(); webView.loadUrl(url); @@ -746,6 +758,7 @@ public void loadWebContent(WebContent webContent) { webView.setWebViewClient(webViewClient); } webView.getSettings().setJavaScriptEnabled(isJavaScriptEnabled); + webView.getSettings().setMediaPlaybackRequiresUserGesture(!allowAutomaticMediaPlayback); if (progressBar == null) { webView.setWebChromeClient(new ChromeLoader()); } else {