Skip to content

Commit

Permalink
1. updated: support SoundCloud playback
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cheung <[email protected]>
  • Loading branch information
Jack Cheung committed Jun 30, 2016
1 parent 9b634de commit 140c7ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/src/main/java/com/hkm/ezwebview/Util/Fx9C.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 140c7ce

Please sign in to comment.