PlayQueueUtils.jsm
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
30 EXPORTED_SYMBOLS = [ "PlayQueueUtils" ];
31 
32 const Cc = Components.classes;
33 const Ci = Components.interfaces;
34 const Cu = Components.utils;
35 
36 Cu.import("resource://app/jsmodules/sbLibraryUtils.jsm");
37 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
38 
40  // Open the play queue display pane
41  openPlayQueue: function PlayQueueUtils_openPlayQueue() {
42  var paneMgr = Cc["@songbirdnest.com/Songbird/DisplayPane/Manager;1"]
43  .getService(Ci.sbIDisplayPaneManager);
44  var contentInfo = Cc["@songbirdnest.com/Songbird/playqueue/contentInfo;1"]
45  .createInstance(Ci.sbIDisplayPaneContentInfo);
46  paneMgr.showPane(contentInfo.contentUrl);
47  },
48 
49  /* Initiates playback from the play queue.
50  * aIndex is optional. If specified play will begin in the playqueue at
51  * that index. If aIndex is not specified play will begin at the index
52  * specified by playQueueService.index
53  */
54  play: function PlayQueueUtils_play(aIndex /* optional */) {
55 
56  if (typeof(aIndex) == "undefined")
57  {
58  var playQueueService = Cc["@songbirdnest.com/Songbird/playqueue/service;1"]
59  .getService(Ci.sbIPlayQueueService);
60  aIndex = playQueueService.index;
61  }
62  var sequencer = Cc["@songbirdnest.com/Songbird/Mediacore/Manager;1"]
63  .getService(Ci.sbIMediacoreManager).sequencer;
64  sequencer.playView(PlayQueueUtils.view, aIndex, true);
65  }
66 }
67 
68 XPCOMUtils.defineLazyGetter(PlayQueueUtils, "view", function() {
69  var playQueueService = Cc["@songbirdnest.com/Songbird/playqueue/service;1"]
70  .getService(Ci.sbIPlayQueueService);
71  return LibraryUtils.createStandardMediaListView(playQueueService.mediaList);
72 });
EXPORTED_SYMBOLS
const Cu
const Ci
var paneMgr
Javascript wrappers for common library tasks.
const Cc
var PlayQueueUtils