27 const Cc = Components.classes;
28 const Ci = Components.interfaces;
29 const Cr = Components.results;
35 const CID =
"2803c9e8-b0b6-4dfe-8333-53430128f7e7";
36 const CONTRACTID =
"@songbirdnest.com/contentlistener/media;1";
51 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
54 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
55 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
67 this._typeSniffer =
Cc[
"@songbirdnest.com/Songbird/Mediacore/TypeSniffer;1"]
68 .createInstance(
Ci.sbIMediacoreTypeSniffer);
69 this._mm =
Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
70 .getService(
Ci.sbIMediacoreManager);
73 _parentContentListener:
null,
87 _handleMediaURI:
function _handleMediaURI(aURI) {
94 if (aURI instanceof
Ci.nsIFileURL) {
96 library = libraryManager.mainLibrary;
97 libraryManager.getContentURI(aURI).spec;
105 library = libraryManager.getLibrary(webLibraryGUID);
111 onEnumerationBegin:
function onEnumerationBegin() {
113 onEnumeratedItem:
function onEnumeratedItem(list, item) {
115 return Ci.sbIMediaListEnumerationListener.CANCEL;
117 onEnumerationEnd:
function onEnumerationEnd() {
122 library.enumerateItemsByProperty(SBProperties.contentURL, url, listener );
123 if (!listener.foundItem) {
124 var mediaItem = library.createMediaItem(aURI);
128 scanArray.appendElement(mediaItem,
false);
130 var metadataService =
Cc[
"@songbirdnest.com/Songbird/FileMetadataService;1"]
131 .getService(
Ci.sbIFileMetadataService);
132 var job = metadataService.read(scanArray);
135 var view = library.createView();
138 [SBProperties.contentURL, [url]]
141 view.filterConstraint =
filter;
143 this._mm.sequencer.playView(view, 0);
146 _handlePlaylistURI:
function _handlePlaylistURI(aURI) {
147 var app =
Cc[
"@songbirdnest.com/Songbird/ApplicationController;1"]
148 .getService(
Ci.sbIApplicationController);
149 var
window = app.activeMainWindow;
151 var
tabbrowser = window.document.getElementById(
"content");
152 tabbrowser.handleMediaURL(aURI.spec,
true,
true,
null,
null);
159 onStartURIOpen:
function onStartURIOpen(aURI) {
166 doContent:
function doContent(aContentType, aIsContentPreferred, aRequest, aContentHandler) {
171 var channel = aRequest.QueryInterface(
Ci.nsIChannel);
172 var
uri = channel.URI;
174 var contentType = channel.contentType;
176 dump(
"\n---------------------------\nsbMediaContentListener -- contentType: " + contentType +
"\n---------------------------\n");
180 if(contentType ==
"text/html" ||
181 contentType ==
"application/atom+xml" ||
182 contentType ==
"application/rdf+xml" ||
183 contentType ==
"application/rss+xml" ||
184 contentType ==
"application/xml") {
193 if (!this._typeSniffer.isValidMediaURL(uri)) {
196 throw Cr.NS_ERROR_UNEXPECTED;
200 this._handleMediaURI(uri);
203 Components.utils.reportError(e);
208 if (!this._typeSniffer.isValidWebSafePlaylistURL(uri)) {
211 throw Cr.NS_ERROR_UNEXPECTED;
215 this._handlePlaylistURI(uri);
218 Components.utils.reportError(e);
232 isPreferred:
function isPreferred(aContentType, aDesiredContentType) {
240 canHandleContent:
function canHandleContent(aContentType, aIsContentPreferred, aDesiredContentType) {
253 get parentContentListener() {
256 set parentContentListener(
val) {
258 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
265 Ci.nsISupportsWeakReference])
280 function preUnregister(aCompMgr, aFileSpec, aLocation) {
const CONTRACTID_LIBRARYMANAGER
const CONTRACTID_OBSERVERSERVICE
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
const CONTRACTID_PREFSERVICE
getService(Ci.sbIFaceplateManager)
this _dialogInput val(dateText)
const PREF_WEBLIBRARY_GUID
sbDeviceFirmwareAutoCheckForUpdate prototype classID
Javascript wrappers for common library tasks.
Array filter(tab.attributes, function(aAttr){return(_this.xulAttributes.indexOf(aAttr.name) >-1);}).forEach(tab.removeAttribute
function sbMediaContentListener()
const CATEGORY_CONTENT_LISTENER
const TYPE_MAYBE_PLAYLIST