Handling Errors for Player V4 Using JavaScript

Error Handling functions and events enable you to get information about Player errors.

The Ooyala Player V4 error functions and events are described in the following tables.

Error Functions

The following table describes the supported error handling functions.

Function Description
getErrorCode Displays the video error code
getState Retrieves the current player state. Possible states are defined in OO.STATE as follows

Error Messages

The following namespaces, described in the Player JavaScript API Reference, contain the error messages that can be handled through the V4 JavaScript Message bus. Use message bus events to handle errors by subscribing to or intercepting the OO.EVENTS.ERROR event:

Error Namespace Description
OO.ERROR Represents the Ooyala V4 Player Errors. This is the parent namespace for all errors, and includes errors for channel content.
OO.ERROR.API Represents errors related to content, metadata, and server connection.
OO.ERROR.API.SAS Represents all authorization-related errors.
OO.ERROR.PLAYBACK Represents all errors related to playback.
OO.ERROR.VC Represents errors related to video element creation and encoding.

Error Events

The following table describes the error handling events published by the message bus.

Error Event Description
PLAYER_CREATED The very first message that is published after player is created, used to notify all plugins to initialize themselves.
ERROR Published when error has occurred, second parameter has error details.
DESTROY Published when player is being destroyed.

Working With the Error Event

The OO.EVENTS.ERROR event is published to the message bus. The mb.subscribe triggers the function you specify (the callback function) when an error happens, and the error continues to propagate to other subscribers. Use mb.subscribe and handle the error as desired according to any existing error-handling functions you might already have in place (such as printing to the console, stopping playback, displaying an error screen, etc). In the following example illustrating the use of the Message Bus subscribe() method, the callback function YourErrorHandlingFunctionNameHere is invoked if the OO.EVENTS.ERROR event is published to the message bus:
    function onCreate(player) {

            function(event, payload) {

    OO.ready(function() {
        window.pp = OO.Player.create('container', 'YOUR_ASSET_ID', {
            "playerBrandingId": "YOUR_PLAYER_ID",
            "pcode": "YOUR_PCODE",
            skin: {
                config: "url_where_hosted/skin-plugin/skin.json",
            // Include the onCreate() function you defined above in these embedded parameters.
            onCreate: window.onCreate

Was this article helpful?