28 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
29 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
31 const Cc = Components.classes;
32 const Ci = Components.interfaces;
33 const Cr = Components.results;
43 var catMan =
Cc[
"@mozilla.org/categorymanager;1"]
44 .getService(
Ci.nsICategoryManager);
46 var category = catMan.enumerateCategory(
"playlist-writer");
49 for (var
entry in ArrayConverter.JSEnum(category)) {
51 var writer =
Cc[catMan.getCategoryEntry(
"playlist-writer",
entry.data)]
52 .createInstance(
Ci.sbIPlaylistWriter);
53 this._writers.push(writer);
57 this._extensions = [];
59 for(var
i in this._writers) {
60 this._extensions = this._extensions.concat(
61 this._writers[
i].supportedFileExtensions({}));
62 this._MIMETypes = this._MIMETypes.concat(
63 this._writers[
i].supportedMIMETypes({}));
70 classID: Components.ID(
"{9d66cb86-951e-49f4-bef8-26a578891275}"),
71 contractID:
"@songbirdnest.com/Songbird/PlaylistWriterManager;1",
79 writePlaylist:
function(aURI, aMediaList, aContentType, aPlaylistWriterListener)
81 if (aURI instanceof
Ci.nsIFileURL) {
82 var
file = aURI.QueryInterface(
Ci.nsIFileURL).file;
85 this.write(file, aMediaList, aContentType, aAddDistinctOnly);
86 if (aPlaylistWriterListener && aPlaylistWriterListener.observer) {
87 aPlaylistWriterListener.observer.observe(aMediaList,
"success",
"");
91 catch(e
if e.result ==
Cr.NS_ERROR_NOT_AVAILABLE) {
99 write:
function(aFile, aMediaList, aContentType, aPlaylistFormatType)
101 var theExtension = this._getFileExtension(aFile);
102 if (!this._writers) {
103 this._cacheWriters();
106 for (var r in this._writers) {
107 var aWriter = this._writers[r];
108 var theExtensions = aWriter.supportedFileExtensions({});
109 var theMIMETypes = aWriter.supportedMIMETypes({});
112 if(theMIMETypes.some(function (a) {
return a == aContentType } ) ||
113 (!aContentType && theExtensions.some(
114 function(a) {
return a == theExtension }))) {
115 aWriter.write(aFile, aMediaList, aContentType, aPlaylistFormatType);
121 throw Cr.NS_ERROR_NOT_AVAILABLE;
124 supportedFileExtensions:
function(nExtCount)
126 if (!this._writers) {
127 this._cacheWriters();
129 nExtCount.value = this._extensions.length;
130 return this._extensions;
133 supportedMIMETypes:
function(nMIMECount)
135 if (!this._writers) {
136 this._cacheWriters();
138 nMIMECount.value = this._MIMETypes.length;
139 return this._MIMETypes;
145 _getFileExtension:
function(aThing)
148 if (aThing instanceof
Ci.nsIURL) {
149 if (
"" != aThing.fileExtension) {
150 return aThing.fileExtension;
153 if (aThing instanceof
Ci.nsIURI) {
156 if (aThing instanceof
Ci.nsIFile) {
157 name = aThing.leafName;
160 var m = /\.([^\.\/]+)$/(name);
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
function NSGetModule(compMgr, fileSpec)
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function sbPlaylistWriterManager()
sbDeviceFirmwareAutoCheckForUpdate prototype classID
_getSelectedPageStyle s i