sbIRemoteSecurityEvent.idl

Summary
A SecurityEvent is passed to any event handlers listening for security permissions status related events fired on the document object.
The Security site scope.
The Security category.
The Security category ID.
Indicates if access is granted for the Security category.

Events

SecurityEvent

A SecurityEvent is passed to any event handlers listening for security permissions status related events fired on the document object.

Note that the Songbird object must be accessed before any events will be raised.  This will likely change in the future.

Example

The JavaScript code.

var myDiv;

function load() {
document.addEventListener('RemoteAPIPermissionChanged', handleEvent, true);
document.addEventListener('RemoteAPIPermissionDenied', handleEvent, true);

myDiv = document.getElementById("output");

// Enumerate some items in the mainLibrary.
var listener = {
onEnumerationBegin: function() {
},
onEnumeratedItem: function(list, item) {
var artistName = item.getProperty("http://songbirdnest.com/data/1.0#artistName");
var trackName = item.getProperty("http://songbirdnest.com/data/1.0#trackName");

//I love this track.
var msg = "I love this song, it's by " +
artistName +
" and I think the track name is " +
trackName;

myDiv.appendChild( document.createTextNode(msg) );
myDiv.appendChild( document.createElement("br") );

// Returning CANCEL stops the enumeration process, returning CONTINUE
// or omitting the return statement continues.
return Components.interfaces.sbIMediaListEnumerationListener.CONTINUE;
},
onEnumerationEnd: function() {
var msg = "I like a lot of tracks."

// I like a lot of tracks.
myDiv.appendChild( document.createTextNode(msg) );
}
};

// Attempt to enumerate all items
songbird.mainLibrary.enumerateAllItems(listener, 0);
}

function unload() {
document.removeEventListener('RemoteAPIPermissionChanged', handleEvent, true);
document.removeEventListener('RemoteAPIPermissionDenied', handleEvent, true);
}

function handleEvent(aEvent) {
var msg = "";

if ( aEvent.type == 'RemoteAPIPermissionDenied' ) {
msg = "You have opted to not configure Songbird so our webpage can interact " +
"with it at it's fullest. Please open tools->options and configure the " +
"RemoteAPI preferences to allow us XYZ permissions. " +
"Below are the permissions that were requested.";

myDiv.appendChild( document.createTextNode(msg) );

myDiv.appendChild( document.createElement("br") );

myDiv.appendChild( document.createTextNode(aEvent.category +
" ( " + aEvent.categoryID + " ) , " +
aEvent.hasAccess));
}
else if( aEvent.type == "RemoteAPIPermissionChanged" ) {
msg = "Thanks! You've granted the following permissions:";

myDiv.appendChild( document.createTextNode(msg) );

myDiv.appendChild( document.createElement("br") );

myDiv.appendChild( document.createTextNode(aEvent.category +
" ( " + aEvent.categoryID + " ) , " +
aEvent.hasAccess) );
myDiv.appendChild(document.createElement("br"));
}

try {
myDiv.appendChild(document.createTextNode(aEvent.originalTarget.location));
} catch (e) { }

myDiv.appendChild(document.createElement("br"));

try {
myDiv.appendChild(document.createTextNode(aEvent.type));
} catch (e) { }

myDiv.appendChild(document.createElement("br"));
}

And then don’t forget to add this to your HTML code.

<body onload="load();" onunload="unload();">
<div id="output">
</div>
</body>

See Also

MediaItem http://developer.mozilla.org/en/docs/DOM:event http://developer.mozilla.org- /en- /docs- /DOM:element.addEventListener

Properties

siteScope

The Security site scope.

Type

URI

category

The Security category.

Type

String

categoryID

The Security category ID.  This is the internal ID for the category.

Type

String

hasAccess

Indicates if access is granted for the Security category.

Type

Boolean

A SecurityEvent is passed to any event handlers listening for security permissions status related events fired on the document object.
Sites can check what security restrictions it has through the songbird javascript object using the Songbird::hasAccess() function.
The Songbird object provides several pieces of functionality to your web page: playback, download, listener adding and removing and library creation and retrieval.
A MediaItem represents a partial or whole piece of media.
The Security category.