Attaching and detaching events - Storm JavaScript Player

Storm player utilizes a simple event-lister model for a direct communication. While actions can be executed using available methods (API), a feedback from player is also necessary.

Attaching an event listener

Attaching an event lister is a straightforward task

const player = stormPlayer(playerGUIConfig, stormLibraryConfig);

player.addEventListener("interfaceReady", function(event){

In this example, we have added a new event listener (called guiInitialized) to the player. Whenever the player GUI becomes ready, an attached function will be called. The function can also be of an inline type.

player.addEventListener("interfaceReady", onGUIInitialized);

And more advanced variation is also possible (and suggested):

Detaching an event listener

In order to detach (remove) an event listener just use:

player.removeEventListener("interfaceReady", onGUIInitialized);

For obvious reasons, inline functions cannot be removed (unless stored as a variable), however, there is a way to remove all events from the player: