It’s important to remember that video playback pauses when the Microphone (voice search) or Home buttons are pressed via remote control inputs). The Back button also pauses the current activity and resumes the previous activity on the stack, which may or may not be your app.
Handling pauses in Android apps
To handle pause behavior in your app, make sure to implement the onPause()
method in your activity as you would in any other Android app. In your onPause()
method, ensure that you save the user’s state or position, so that when your app resumes the user is in the same place that they were before the pause.
In addition, the following requirements apply to media apps:
- Apps that play video should pause playback, and must release all media resources such as decoders immediately on pause, as these limited resources are hardware-based and memory-constrained. See Releasing the Media Player and
MediaPlayer.release
for details. - Apps that play audio may continue playing after a pause, but must relinquish audio focus if requested by another app. See Audio Focus for details.
Handling pauses in Web apps
Web applications must respond accurately to user initiated pauses. When a user pauses the video using the remote control’s pause button, the app must respond accordingly. Applications that don’t correctly handle the system initiated video pauses don’t show the video controls to the user.
To show video controls in response to video pauses initiated by the system, your app should listen for video element’s pause event and show the controls in the pause event handler. In addition, if your app is using the Amazon HTML5 Web App platform API, listen for pause / resume / visibility change events and have the app react appropriately.
/**
* Add listeners to handle events from native
*
* NOTE : You can use either pause and resume, or you
* can use the visibilty events to detect whether your
* app has gone to the background/come to the foreground
*/
function onAmazonPlatformReady() {
//add native event listeners
document.addEventListener("pause" , onPause, false);
document.addEventListener("resume" , onResume, false);
document.addEventListener('webkitvisibilitychange', handleVisibilityChange);
document.addEventListener('visibilitychange', handleVisibilityChange);
}
Read the Getting Started with Web Apps (Fire TV) | Amazon Fire TV docs for using the Amazon Web App platform API.
Lastly, you can find a simple web app video pausing sample here.
Related: