Skip to main content

HTML App API

Intro

The Player needs to notify the App of the current state of playback. The Player calls several hooks during playback so that the App can properly update its status. Also, the Player provides an API to allow the App to perform actions or retrieve additional information from the Player.

Sequence of Calls

To provide seamless transitions, the Player performs preloading of the following content. Every time content is shown on screen, the next item in the Playlist is loaded so that the transition is as fast as possible.The standard sequence of events is the following:

  1. The App is loaded on the Player's web viewer.

  2. The init_widget hook is called. (called right after the App loading has completed)

  3. The App awaits preloaded to be shown on the screen.

  4. The show_widget hook is called. (called just before the App is shown on screen)

  5. The start_widget hook is called. (called just after the App is shown on the screen )

  6. The App is playing back normally.

  7. The hide_widget hook is called. (called just before the App is removed from the screen )

  8. The stop_widget hook is called. (called just after the App is removed on screen )

  9. The App awaits to be destroyed.

  10. The Player's web viewer is destroyed.


HTML App Hooks

init_widget

Initialization hook for the App.

init_widget(config)

This is the most frequently used hook. This hook is called right after the App has completed loading. The config argument is an object that carries all the App configuration options defined for the App.If an App does not provide configuration options, you can safely skip providing this function in your App code. Note that this hook is called just after the onload() call completes.

show_widget

Show hook for the App.

show_widget()

To keep transitions smooth, the Player loads the next App in the background before it appears on screen. The Player calls show_widget() at the last moment before your App becomes visible, just before start_widget(). By this point your App is fully loaded and initialized, but not yet on screen.Use this hook only for something that must happen right before the App appears. Anything that should run once the App is on screen, such as playback, animations or data updates, belongs in start_widget(). In practice, very few Apps need this hook.You can safely skip providing this function in your App code if you do not need it.Remember that this hook should be kept minimal and with zero delays since it may disrupt transitions.

start_widget

Playback start hook for the App.

start_widget()

Content on Player is preloaded before it appears on screen to provide a more seamless transition between content. This hook is called right after the App has been shown on screen. This hook might be needed in the following cases:

  • The App is CPU intensive, so you can use it to prevent unnecessary CPU load between loading the App and showing the App.

  • The App might need to know when to start playback., e.g., if it needs to playback a series of images.

  • The App might use bandwidth to update its data, so bandwidth can be saved if updates do not occur when the App is not visible.

You can safely skip providing this function in your App code if you do not need it. Remember that this hook should be kept minimal and with zero delays since it may disrupt transitions.

hide_widget

Hide hook for the App.

hide_widget()

This hook is called right before the App viewer is moved off-screen. The use cases for this hook are very rare.You can safely skip providing this function in your App code if you do not need it. Remember that this hook should be kept minimal and with zero delays since it may disrupt transitions.

stop_widget

Playback stop hook for the App.

stop_widget()

This hook is called right after the App viewer has been moved off-screen. This hook might be needed in the following cases:

  • The App saves some state on a backend server when it finishes, so it needs to do some work before it is terminated.

  • The App might use CPU or bandwidth until the web viewer is actually destroyed so that these resources can be saved in the meantime.

You can safely skip providing this function in your App code if you do not need it.


HTML App API Calls

exit_widget

Notify the Player that the App has finished playback.

exit_widget()

This function allows your App to notify the Player that the App has completed playback and the viewer should terminate. This allows your App to get the Player to proceed to the next content item in the Playlist.Note that this function notifies the Player; it does not cause the App to exit instantly. The Player will go through the transition flow, calling all required hooks detailed above.

Did this answer your question?