Companywebcast API Wiki
Navigation
Cwc API Home
PlayerSDK
Meta Service
Getting Started
Creating a client
Methods
Data Types
Understanding Webcast security
Management Service
Getting Started
Creating a client
Methods
Data Types
Quick Search
Advanced Search »
Back
History
StateMachine 1.0 : Getting Started
StateMachine contains lots of usefull functionality, but here are the basic functions that will get you started: * Cwc.PlayerService.WebcastSearch() * Cwc.PlayerService.WebcastGet() * Cwc.CreateStateMachine() That sounds more complicated than it really is... let's look at some sample code. <code javascript> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title></title> < script src="http://services.companywebcast.com/StateMachine/0.9/js/Cwc.StateMachine.js" type="text/javascript"></script> < script src="http://services.companywebcast.com/StateMachine/0.9/js/Cwc.StateMachine.MediaRenderer.js" type="text/javascript"></script> < script type="text/javascript"> window.onload = function() { Cwc.CreateStateMachine([{ Code: "apeldoorn/20090702_4/nl"}], function(StateMachine, e) { if (e.Success) { //We've successfully authorized for "apeldoorn/20090702_4/nl", //retrieved its metadata and used it to instantiate a StateMachine. //Subscribe to the event that is fired when the current speaker in this webcast changes StateMachine.State.CurrentSpeakerChangedEvent.Subscribe(function() { var CurrentSpeaker = StateMachine.State.getCurrentSpeaker(); if (CurrentSpeaker.LastName) alert(CurrentSpeaker.LastName); }); //Add the MediaRenderer of this StateMachine to the page. document.getElementById("VideoContainer").appendChild(StateMachine.MediaRenderer); } }); } </script> </head> <body> <div id="VideoContainer" style="width:320px;height:240px;"> </div> </body> </html> </code> The example above displays the video stream for the webcast with Code "apeldoorn/20090702_4/nl", and fires an alert containing the speaker's last name, every time the current speaker changes.