CB-11013 IAB enabling background play of YouTube videos?

Adds shouldPause feature to stop backgound audio
This commit is contained in:
daserge
2016-08-16 21:22:32 +03:00
parent 2776b14db6
commit 698648f15d
2 changed files with 27 additions and 0 deletions
+26
View File
@@ -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.
@@ -265,6 +267,26 @@ public class InAppBrowser extends CordovaPlugin {
closeDialog();
}
/**
* 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;