Lifecycle Integration

The Senza platform operates in two modes:

  1. In foreground mode, your web app runs in a browser in the cloud, and the user interface is streamed to the cloud connector as a video.
  2. In background mode, video content is streamed directly from the CDN to the cloud connector.

When your app is running in the browser in foreground mode, it consumes CPU and GPU resources that count towards your platform usage minutes. In background mode, the browser consumes fewer resources, so time spent does not count towards your platform usage. Therefore you'll want to adapt your app to use background mode as much as possible.

Background mode is primarily used for playing video streams, but you can also switch to background mode if you are not playing a video. If the remote player is not playing a video, the cloud connector will continue to display the last frame rendered by the web browser.

When to use foreground mode

When the user is interacting with your app

In this case your web app runs as normal in the browser in the cloud. When the user presses buttons on the remote control, user input events are sent to your app as key presses, and your app can update the interface in real time to respond to their commands.

When you want to combine video with other elements

Your app may want to present video full screen combined with other HTML user interface elements layered on top, such as playback controls, content metadata, or augmented experiences. In this case you would stay in foreground mode so that the browser can composite the video and other elements.

When content on the screen is changing

In non-interactive use cases such as digital signage, your app may need to update the content on the screen periodically or display animations. Any time your app needs to update the contents of the web page, you'll need to do so in foreground mode.

When to use background mode

When the user is watching full screen video

When your app is ready to play video without other user interface elements, switch to background mode. Video will then stream directly to the cloud connector.

During periods of inactivity

Users may interact with your app intermittently; for example, they may walk away from the TV to make a cup of tea. You can save resources by switching to background mode after a period of inactivity. Depending upon the functionality of your app, you could:

  • continue playing a video that the user has been watching
  • play another video, like a screen saver on a computer
  • switch to background mode without playing a video, which will simply freeze the screen

When the content on screen isn't changing

In non-interactive use cases, if your app will display the same content on screen for a period of time without needing to update it, you can switch to background mode to save resources. If you want to update the screen later after a period of time, you can set a timer or use the Alarm Manager to switch back to foreground mode.

Programming Techniques

  • Switching Modes: shows how to switch between foreground and background modes, including doing this automatically with the Auto Background feature.
  • Lifecycle Events: shows how your app can be notified when the lifecycle changes modes, the user has been inactive, or the session has disconnected.

Example Apps

  • Playing Video: A step-by-step guide to the reference implementation.
  • Program Guide: Demonstrates how to integrate a full featured app with just a few lines of code.
  • Video Signage: Shows how to make a digital signage app that takes advantage of background mode.