How to use events using Clipstream Player API

You can set a Javascript function callback using a variety of triggering events. 

Launch function when player is ready event

This will launch a defined function when the player is fully loaded on a page. This requires you first launch a function on the page load (onload) that will ready the Clipstream player to launch when it is ready.

Syntax:

window.clipstream.onready = myfunc;

Example:

window.onload = launchWhenClipstreamReady () {
       window.clipstream.onready = launchWhenReady;
}

function launchWhenReady {

     alert('player is ready!');
}

 

Launch function on play event

This will launch a defined function when the player is played.

Syntax:

window.clipstream.players[0].setCallbackOnPlay( function () { () } ); 

Example:

<a href="#" onClick="window.clipstream.players[0].setCallbackOnPlay( function () { alert('I'm playing') } );">Click to set CallbackOnPlay</a>

 

Launch function on stop event

This will launch a defined function when the player stops.

Syntax:

window.clipstream.players[0].setCallbackOnStop( function () { () } ); 

Example:

<a href="#" onClick="window.clipstream.players[0].setCallbackOnStop( function() { alert('I'm stopped!') } );">Click to set CallbackOnStop</a>

 

Alternate method:

https://destinymedia.zendesk.com/hc/en-us/articles/206108907-Triggering-a-Javascript-function-from-your-video-callback-

 

Launch function on set events (on play, pause, stop, mute, second, interval of seconds)

Set a callback based upon a defined player event or time.

Syntax:

player.setCallback(play|pause|stop|mute|{sec}[/{sec_interval],  function () { ... } );  

Example:

<a href="#" onClick="player.setCallback(stop,nextButton(););">Have next button appear when video stopped</a>

Launch a function at certain time events

Set a function to launch when the video reaches a specified time or series of times. Use floating seconds to specify timing.   The first number passed is the offset time when the callback will start and the second number is the interval.

Syntax:

player.setCallback( 'sec/sec',(function() { } );

Example:

This function will be called every 20 seconds starting at 15 seconds.

player.setCallback( '15.000/20.000',(myfunction() {alert('hi there') } );

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk