top

Player crash on application exit

Published 2014-10-28 | (Compatible with SDK 5.0,5.1 and 2014 models)

How to avoid unexpected player behavior on application exit

Contents

If your application uses the player plugin for video or audio playback, you must call the player Stop operation when the application is shut down. Without this, the player plugin may not be terminated correctly and may generate errors.

Please note that some of the remote controller keys (as SmartHub, Content, Menu or Source) automatically close the application because they are handled by the manager widget and not the app itself. When one of these keys is pressed, the body onUnload callback function is called. In case the application is build with Application Framework, the callback function is located in init.js file and called onDestroy().

To prevent the system crash, you must always call the pluginPlayer.Stop() function in the onUnload callback.

Example

var WIDGET = new Common.API.Widget();        // For sendReadyEvent()

Main.onLoad = function() {
    window.onShow = onShowEvent;
    WIDGET.sendReadyEvent();
};

var onShowEvent = function() {
    var pluginPlayer = caph.platform.dtv.Device.plugin("PLAYER");
    pluginPlayer.Play();
};

window.onHide = function() {
    pluginPlayer.Stop();
};

Main.onUnload = function() {

}