CB-11013 IAB enabling background play of YouTube videos?
Adds shouldPause feature to stop backgound audio
This commit is contained in:
parent
2776b14db6
commit
698648f15d
@ -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`.
|
- __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.
|
- __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`).
|
- __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:
|
iOS only:
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||||
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
|
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
|
||||||
private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
|
private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
|
||||||
|
private static final String SHOULD_PAUSE = "shouldPauseOnSuspend";
|
||||||
|
|
||||||
private InAppBrowserDialog dialog;
|
private InAppBrowserDialog dialog;
|
||||||
private WebView inAppWebView;
|
private WebView inAppWebView;
|
||||||
@ -99,6 +100,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private boolean clearSessionCache = false;
|
private boolean clearSessionCache = false;
|
||||||
private boolean hadwareBackButton = true;
|
private boolean hadwareBackButton = true;
|
||||||
private boolean mediaPlaybackRequiresUserGesture = false;
|
private boolean mediaPlaybackRequiresUserGesture = false;
|
||||||
|
private boolean shouldPauseInAppBrowser = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the request and returns PluginResult.
|
* Executes the request and returns PluginResult.
|
||||||
@ -265,6 +267,26 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
closeDialog();
|
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.
|
* Called by AccelBroker when listener is to be shut down.
|
||||||
* Stop listener.
|
* Stop listener.
|
||||||
@ -514,6 +536,10 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
clearSessionCache = cache.booleanValue();
|
clearSessionCache = cache.booleanValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Boolean shouldPause = features.get(SHOULD_PAUSE);
|
||||||
|
if (shouldPause != null) {
|
||||||
|
shouldPauseInAppBrowser = shouldPause.booleanValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CordovaWebView thatWebView = this.webView;
|
final CordovaWebView thatWebView = this.webView;
|
||||||
|
Loading…
Reference in New Issue
Block a user