Repository: cordova-plugin-inappbrowser Updated Branches: refs/heads/master 2776b14db -> 698648f15
CB-11013 IAB enabling background play of YouTube videos? Adds shouldPause feature to stop backgound audio Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/698648f1 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/698648f1 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/698648f1 Branch: refs/heads/master Commit: 698648f15d4c2297ebc478f4437f7d192e4810a6 Parents: 2776b14 Author: daserge <v-ses...@microsoft.com> Authored: Tue Aug 16 21:22:32 2016 +0300 Committer: daserge <v-ses...@microsoft.com> Committed: Thu Aug 18 18:25:38 2016 +0300 ---------------------------------------------------------------------- README.md | 1 + src/android/InAppBrowser.java | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/698648f1/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index e1d81b8..9781ebc 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ instance, or the system browser. - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). + - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). iOS only: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/698648f1/src/android/InAppBrowser.java ---------------------------------------------------------------------- diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 38c3cbc..5a9b9af 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -87,6 +87,7 @@ public class InAppBrowser extends CordovaPlugin { private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; private static final String HARDWARE_BACK_BUTTON = "hardwareback"; private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction"; + private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -99,6 +100,7 @@ public class InAppBrowser extends CordovaPlugin { private boolean clearSessionCache = false; private boolean hadwareBackButton = true; private boolean mediaPlaybackRequiresUserGesture = false; + private boolean shouldPauseInAppBrowser = false; /** * Executes the request and returns PluginResult. @@ -266,6 +268,26 @@ public class InAppBrowser extends CordovaPlugin { } /** + * Called when the system is about to start resuming a previous activity. + */ + @Override + public void onPause(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onPause(); + } + } + + /** + * Called when the activity will start interacting with the user. + */ + @Override + public void onResume(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onResume(); + } + } + + /** * Called by AccelBroker when listener is to be shut down. * Stop listener. */ @@ -514,6 +536,10 @@ public class InAppBrowser extends CordovaPlugin { clearSessionCache = cache.booleanValue(); } } + Boolean shouldPause = features.get(SHOULD_PAUSE); + if (shouldPause != null) { + shouldPauseInAppBrowser = shouldPause.booleanValue(); + } } final CordovaWebView thatWebView = this.webView; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org