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 {