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.


window.clipstream.onready = myfunc;


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.


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


<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.


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


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


Alternate method:


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.


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


<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.


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


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


Please sign in to leave a comment.
Powered by Zendesk