My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Sonettic-Cinema Advanced JavaScript API

This is an Open Source JavaScript library for work with Sonettic-Cinema Player HD Developer version and for all of the commercial versions of the player.

It's free, it's open and it's powerful.

How it works

Advanced JavaScript API design based on Event model (Observer design pattern). Player and JavaScript communicate through events and all events either from Player or from JavaScript may contain arguments. List of all available events and its arguments in Player Events document.

Ready callback function

Method ready of SntPlayer object with necessary argument callback function will be invoked after initialization of Flash Object with Player on the webpage. Adding of new event listeners or sending events to the Player have to be inside of callback function. If you add new events listeners or send it inside callback function then it will be guarantee that your events will be sent to the player and will be received from it.


Short Tutorial

How to initialize JavaScript API Instance:

<script type="text/javascript">

// Flash Object ID
var videoHolderName = 'player2holder';

// create SntPlayer object instance
var player = new SntPlayer(videoHolderName);

// here we set player callback function
player.ready(function(r){
	// handle and send events to player instance here
});
</script>

Write this code inside of player.ready() callback function

How to send event to the Player:

player.sendMessage('uiPlayClick');

How to receive event to the Player:

// play event listener
var onPlayEvent = function(){
	// change text on the control
	play_button.value = 'pause';
	
	// change click handler
	play_button.onclick = pauseEvent;	
};

player.addEventListener('mediaPlay', onPlayEvent);
Powered by Google Project Hosting