Data Remotes & Observers

Songbird has a bunch of different listening & observing methods to hook into if you want to have code fire upon event initiation and completion.  Typically, most people are interested in hooking into media playback.

Media Playback Observers 

If you would like to be informed about media playback events, please see the Media Playback recipe for how to add an observer to the Media Core Manager.

Data Remotes

For events that aren't handled by sbIPlaylistPlaybackListener, you can also use Songbird's DataRemotes mechanism for observing events.  By examining playerControls.xml you can see many of the controls emit "dataremotes" such as "faceplate.mute" and "faceplate.playing".  We also have a full list of the dataremote listener topics in the Webpage API Documentation.  You can bind arbitrary observers to these data remotes by creating a new data remote and then binding the observer to it like so:

var myDataRemoteObserver = {
    observe: function(subject, topic, data) {
        alert(subject + " -- " + topic + " -- " + data);
    }   
}   

const SONGBIRD_DATAREMOTE_CONTRACTID = "@songbirdnest.com/Songbird/DataRemote;1";
var createDataRemote = new Components.Constructor( SONGBIRD_DATAREMOTE_CONTRACTID,
    Components.interfaces.sbIDataRemote, "init");
var myPauseDataRemote = createDataRemote("faceplate.paused", null);
myPauseDataRemote.bindObserver(myDataRemoteObserver, true);
Tag page
You must login to post a comment.