sbIRemoteLibrary.idl
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25  */
26 
32 #include "nsISupports.idl"
33 #include "sbIRemoteMediaList.idl"
34 
35 interface nsISimpleEnumerator;
36 interface nsIStringEnumerator;
37 interface sbIMediaItem;
38 interface sbIMediaList;
39 interface nsIVariant;
40 
41 [scriptable, function, uuid(27bfbb84-ac22-46bd-b1bb-cf3baf6f3b3c)]
43 {
44  void onCreated(in sbIMediaList aMediaList);
45 };
46 
47 /*
48 Class: Library
49 
50 A <Library> is a collection of <MediaItems> and <MediaLists>.
51 It is possible to create a <Library> using the <Songbird::siteLibrary>
52 function.
53 
54 Inherits:
55  <MediaList> <MediaItem>
56 
57 Example:
58  (start code)
59  //Create or get a library.
60  var library = songbird.siteLibrary("", "");
61 
62  //Create a medialist using the library.
63  var mediaList = library.createSimpleMediaList("Name of List");
64 
65  //Create some mediaitems and add them to the medialist.
66  var itemURLs = ["http://path/to/song.mp3", "http://path/to/another/song.mp3"];
67  for(var url in itemURLs) {
68 
69  //Calling createMediaItem may throw an exception when it fails
70  //to create the mediaitem.
71 
72  try {
73  var mediaItem = library.createMediaItem(url);
74  mediaList.add(mediaItem);
75  }
76  catch(e) {
77 
78  //Dump it.
79  dump("Failed creation of mediaitem: " + e);
80 
81  //Or alert it.
82  alert("Failed creation of mediaitem: " + e);
83 
84  //Oops the URL was not valid.
85  if(e.result == Components.results.NS_ERROR_INVALID_ARG) {
86  alert("The URL: " + url + " was not valid.");
87  }
88 
89  }
90  }
91  (end code)
92 
93 See Also:
94  <Songbird>
95  <MediaItem>
96  <MediaList>
97 */
98 
110 [scriptable, uuid(a8193c8e-4f9a-4b31-ae7b-4f4ee07f4efb)]
112 {
124  /*
125  Group: Library Properties
126  */
127 
128  /*
129  Prop: scanMediaOnCreation
130 
131  Set this property to true if you wish all new <MediaItems>
132  created to be scanned for metadata.
133 
134  Set this property to false if you wish to skip scanning
135  for metadata when <MediaItems> are created.
136 
137  If you are attempting to set all of your own metadata for <MediaItems>
138  you create, you may set this to false to prevent your metadata
139  from being overwritten.
140 
141  Note:
142  This property defaults to _true_.
143 
144  Type:
145  Boolean
146  */
147  attribute boolean scanMediaOnCreation;
148 
160  /*
161  Group: Library Methods
162  */
163 
164  /*
165  Method: createMediaItem()
166 
167  Create a <MediaItem> from a URL. You may pass in
168  http and https URLs. Local file URLs are not permitted.
169 
170  Prototype:
171  <MediaItem> createMediaItem(String url)
172 
173  Parameters:
174  url - A URL referring to a media file.
175 
176  Returns:
177  The newly created <MediaItem>.
178 
179  Throws:
180  Invalid Argument (Components.results.NS_ERROR_INVALID_ARG)
181  if the URL isn't http or https.
182 
183  Example:
184  (start code)
185  //Create or get a library.
186  var library = songbird.siteLibrary("", "");
187 
188  //Create the mediaitem from a url pointing to a media file.
189  var mediaItem = null;
190 
191  //This function may throw if it fails to create the item because
192  //the URL is invalid.
193  try {
194  mediaItem = library.createMediaItem("http://path/to/file.mp3");
195  }
196  catch(e) {
197  //Oops, bad URL.
198  if(e.result == Components.results.NS_ERROR_INVALID_ARG) {
199  alert("Oops, the URL was not valid.");
200  }
201  }
202  (end)
203 
204  Note:
205  Metadata for the <MediaItems> may get updated and overwritten during playback.
206  See <Metadata Updates> for more details about cases where metadata may
207  get updated.
208 
209  See Also:
210  <createSimpleMediaList()>
211  <createMediaListFromURL()>
212  */
213  sbIMediaItem createMediaItem(in AString aURL);
214 
228  /*
229  Method: createSimpleMediaList()
230 
231  Create a simple <MediaList> with the given name.
232 
233  Prototype:
234  <MediaList> createSimpleMediaList(String name, String siteID)
235 
236  Parameters:
237  name - The name of the <MediaList> to create.
238  siteID - An optional siteID to assign. If unspecified then the siteID will
239  use the value passed for name.
240 
241  Returns:
242  The newly created <MediaList> or null.
243 
244  Example:
245  (start code)
246  //Create or get a library.
247  var library = songbird.siteLibrary("", "");
248 
249  //Create an empty medialist.
250  var mediaList = library.createSimpleMediaList("MyList");
251  (end)
252 
253  See Also:
254  <createMediaItem()>
255  <createSimpleMediaList()>
256  <createMediaListFromURL()>
257  */
259  [optional] in AString aSiteID);
260 
276  /*
277  Method: createMediaListFromURL()
278 
279  Create a <MediaList> from a URL. The URL may point to an
280  m3u, pls, rss or html file. After being created, the <MediaList>
281  will contain all valid <MediaItems> it could create from the URLs
282  it found in the file.
283 
284  Prototype:
285  <MediaList> createMediaListFromURL(String url, Function callback)
286 
287  Parameters:
288  url - The URL of the file to use for creating the <MediaList>.
289  callback - The optional function that gets called when the load is complete.
290  This function is passed a single argument that is the newly
291  created list.
292 
293  Example:
294  (start code)
295  //Create or get a library.
296  var library = songbird.siteLibrary("", "");
297 
298  //Create the medialist from a url pointing to a file.
299  library.createMediaListFromURL("http://path/to/file.m3u",
300  function(list) {
301  alert("loaded " + list.length + " items!");
302  }
303  );
304  (end)
305 
306  See Also:
307  <createMediaItem()>
308  <createSimpleMediaList()>
309  */
310  void createMediaListFromURL(in AString aName,
311  in AString aURL,
312  [optional] in sbICreateMediaListCallback aCallback,
313  [optional] in AString aSiteID);
314 
323  [noscript] void connectToDefaultLibrary(in AString aLibName);
324 
331  /*
332  Method: getMediaListBySiteID()
333 
334  Get the site media list with the given siteID.
335 
336  Prototype:
337  <MediaList> getMediaListBySiteID(String siteID)
338 
339  Paramters:
340  name - The siteID of the media list to fetch
341 
342  Returns:
343  The corresponding media list, or null if not found
344 
345  Example:
346  (start code)
347  //Create or get a library.
348  var library = songbird.siteLibrary("", "");
349 
350  //Fetch the shopping cart media list
351  var mediaList = library.getMediaListBySiteID("Shopping Cart");
352  (end)
353 
354  See Also:
355  <createSimpleMediaList()>
356  */
357  sbIRemoteMediaList getMediaListBySiteID( in AString aSiteID );
358 
359  /*
360  Method: getPlaylists()
361 
362  Get an Enumerator containing all of the <MediaLists> in the <Library>.
363 
364  Prototype:
365  Enumerator getPlaylists()
366 
367  Returns:
368  An Enumerator containing all of the
369  <MediaLists> present in the <Library>.
370 
371  Example:
372  (start code)
373  //Create or get a library.
374  var library = songbird.siteLibrary("", "");
375 
376  //Get all MediaLists.
377  var mediaLists = library.getPlaylists();
378 
379  while(mediaLists.hasMoreElements()) {
380  var mediaList = mediaLists.getNext();
381 
382  //Do something with the MediaList
383  alert(mediaList.name);
384  }
385  (end)
386 
387  See Also:
388  <getArtists()>
389  <albums>
390  <genres>
391  <years>
392 
393  External Reference:
394  Please see <http://www.xulplanet.com/references/xpcomref/ifaces/nsISimpleEnumerator.html> for nsISimpleEnumerator interface reference.
395  */
396  readonly attribute nsISimpleEnumerator playlists;
397 
398 
399  /*
400  Method: mostPlayedArtists
401 
402  Get the most played artists from the <Library>.
403 
404  Prototype:
405  Array mostPlayedArtists
406 
407  Returns:
408  An array of the most played artists - up to 100.
409 
410  Example:
411  (start code)
412  var artists = window.songbird.mainLibrary.mostPlayedArtists;
413  for (var i in artists) {
414  var elem = document.createElement('li');
415  elem.textContent = artists[i];
416  output.appendChild(elem);
417  }
418  (end)
419 
420  See Also:
421  <artists>
422  */
423 
424  readonly attribute nsIVariant mostPlayedArtists;
425 };
426 
438 [scriptable, uuid(023734d0-0ba2-4c19-9fe6-58646282b586)]
440 {
445  readonly attribute AString filename;
446 
472  [noscript] void connectToSiteLibrary(in AUTF8String aDomain,
473  in AUTF8String aPath);
474 };
sbIRemoteMediaList getMediaListBySiteID(in AString aSiteID)
Get the media list with the given siteID.
sbIMediaItem createMediaItem(in AString aURL)
Create a media item from a URL.
_updateCookies aPath
Definition of the Remote API Media List Interface.
readonly attribute AString filename
The filename of the library file Set only in debug builds.
var uuid
A brief description of the contents of this interface.
void connectToSiteLibrary(in AUTF8String aDomain, in AUTF8String aPath)
Connects the remote library to a library from the internal data model.
attribute boolean scanMediaOnCreation
Control whether or not media is scanned when created.
An interface for a sandbox library created by the website.
readonly attribute nsISimpleEnumerator playlists
readonly attribute nsIVariant mostPlayedArtists
sbIRemoteMediaList createSimpleMediaList(in AString aName, [optional] in AString aSiteID)
Create a simple media list.
void connectToDefaultLibrary(in AString aLibName)
Connect the remote library to the main or web library.
void createMediaListFromURL(in AString aName, in AString aURL, [optional] in sbICreateMediaListCallback aCallback, [optional] in AString aSiteID)
Create a media list from an exising playlist file.
void onCreated(in sbIMediaList aMediaList)
An interface to control a media library from remote web pages.
_updateCookies aName
Interface that defines a single item of media in the system.
An interface to control a media list from remote web pages.