Whether you are working with Songbird as an extension, or by way of the Webpage API - if you want to do any sort of integration into Songbird's media player capabilities you will need to understand a few key concepts about Songbird's architecture and how to access its libraries, playlists, and tracks.
Whether you're a first-timer, or an experienced Songbird developer, using our source browser to look through the interface definitions (the .IDL files) will be an invaluable tool.
We also have automatically-generated API documentation available for all the interfaces.
Objects representing media in Songbird are quite hierarchical. Whether it's a library, playlist, or track - if it's conceptually part of the media library - then it must implement both the sbILibraryResource interface as well as sbIMediaItem. If it's a playlist, then it must, in addition to the above two, implement the sbIMediaList interface. And finally, if it's a library, then it must implement all of the above, as well as sbILibrary.
.guid .created / .updated .userEditable .getProperty(propertyName) .setProperty(propertyName, propertyValue) sbILibraryResource API reference for more information.http://songbirdnest.com/data/1.0#artistName
Extensions, and web pages (via the Webpage API) can create arbitrary properties to help manage their own metadata they may wish to assign to resources, so having properties in the form of a namespace URL gives more guarantees in what could otherwise be a messy and competitive global namespace.
The standard set of properties Songbird ships with is in sbStandardProperties.h which is available for any C/C++ extension to include. Javascript code can import (via Components.utils.import) the sbProperties.jsm which gets generated from the above .h file, and makes all of Songbird's default properties available via the form: SBProperties.<propertyName>, e.g.:
Components.utils.import("resource://app/jsmodules/sbProperties.jsm")
alert(myItem.getProperty(SBProperties.artistName));
All sbIMediaItems provide the following members (note that there are other members available, and we recommend viewing the sbIMediaItem API reference for more exhaustive detail)
.library sbILibrary to which this item belongs to. This is useful for backtracking from a given item to its owning library (for example, if you grab the currently playing item from the sbIMediacoreSequencer).isMutable .contentSrc nsIURI with the URL to the media..contentLength sbIMediaList interface. There are quite a few members and methods available off this interface, so you should make sure to consult the API reference for the full list. Because an sbIMediaList is also an sbIMediaItem, you can distinguish whether an sbIMediaItem is a list or not by examining the isList property, e.g.:
if (myItem.getProperty(SBProperties.isList) == "1") {
alert(myItem.guid + " is an sbIMediaList");
} else {
alert(myItem.guid + " is just a regular sbIMediaItem");
}
.name .type .length .isEmpty .userEditableContent .getItemByGuid(guid) sbIMediaItem if it's within this list.getItemByIndex(index) sbIMediaItem .enumerateAllItems() .enumerateItemsByProperty() .enumerateItemsByProperties() .getItemsByProperty() enumerateItemsByProperty(), except it returns an nsIArray of items instead of an enumeration.getItemsByProperties() enumerateItemsByProperties(), except it returns an nsIArray of items instead of an enumeration.indexOf(mediaItem) sbIMediaItem, returns the index of the item within the playlist.lastIndexOf(mediaItem) .contains(mediaItem) .getDistinctValuesForProperty() add(mediaItem) addAll(mediaList) addSome(enumerator of mediaItems) remove(mediaItem) removeByIndex(index) removeSome(enumerator of mediaItems) clear() sbIMediaLists also allow you to add listeners. These listeners are triggered depending on the flags they are added with. For instance, you can add listeners to fire when the list itself is modified (e.g. metadata about the list), or when the list contents are modified (items are added, removed, changed, etc.).
addListener(sbIMediaListListener)removeListener(sbIMediaListListener)sbIMediaListListener interfaces, please see the Media List Listeners recipe.sbIMediaLists can also be filtered and searched upon by creating sbIMediaListView objects from them. An sbIMediaListView of a list is a way to filter based on properties, or search by full-text-search filtering. To create an sbIMediaListView, you can simply do myList.createView(). Please read our further overview on sbIMediaListViews and how you can filter/search lists/libraries and present them to the end-user.
sbILibrary is derived from an sbIMediaList and is really just a special case of lists. One major difference is that while a list can contain the same sbIMediaItem multiple times (since it is just an ordered playlist), a library can only contain unique items, and is inherently unordered.sbILibrary API reference for a full list of the interfaces with more complete comments. Some of the important methods to know that sbILibrary items implement are:
.createMediaItem(URI) nsIURI to some media, create a new media item to represent it.createMediaList(type) .copyMediaList(type, sourceMediaList) .getMediaItem(GUID) .batchCreateMediaItems().batchCreateMediaItemsAsync() Songbird provides an sbLibraryUtils JSM which you can import with:
Components.utils.import("resource://app/jsmodules/sbLibraryUtils.jsm");
You can then access things like the mainLibrary via:
alert(LibraryUtils.mainLibrary.length);
For more information, please see our JSM documentation for sbLibraryUtils.jsm.
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |