Skip to main content
Skip table of contents

Error handling during intialisation

There may be a failure during player initialization which results in the player object not being returned. Since there is no object instance to attach listeners onto, no errors can be caught.

To deal with this the otvtoolkit allows for a creationFailureCallback property on its plugin options. In the event of an error during initialisation, this will be called with an error object passed in as the only parameter.

The error object will have a name and a message property that can be used to determine the nature of the error.

JS
let playerInstance = otvplayer(
    "videoPlayer",
    // options
    {
        plugins: {
            otvtoolkit: {
                creationFailureCallback: onCreationFailureCallback
            }
        }
    },
    // loaded callback
    function loadedCallback() {
    ...
    }
);
 
function onCreationFailureCallback(creationError) {
  console.error(creationError.name + ": " + creationError.message);
}

An invalid video ID being passed to the player, otvplayer will generate a TypeException, for an invalid plugin or plugin component, otvplayer will generate a ReferenceException.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.