30 if (typeof(
Cc) ==
"undefined")
31 var
Cc = Components.classes;
32 if (typeof(
Ci) ==
"undefined")
33 var
Ci = Components.interfaces;
34 if (typeof(
Cr) ==
"undefined")
35 var
Cr = Components.results;
36 if (typeof(
Cu) ==
"undefined")
37 var
Cu = Components.utils;
39 Cu.import(
"resource://app/jsmodules/DebugUtils.jsm");
40 Cu.import(
"resource://app/jsmodules/kPlaylistCommands.jsm");
41 Cu.import(
"resource://app/jsmodules/PlayQueueUtils.jsm");
42 Cu.import(
"resource://app/jsmodules/SBDataRemoteUtils.jsm");
43 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
47 _LOG: DebugUtils.generateLogFunction(
"sbPlayQueue", 5),
52 onLoad:
function playQueue_onLoad() {
55 this._playlist = document.getElementById(
"playqueue-playlist");
56 this._playlistBox = document.getElementById(
"playqueue-playlist-box");
57 this._innerMessageBox =
58 document.getElementById(
"playqueue-message-layer-inner-box");
60 document.getElementById(
"playqueue-message-layer-outer-box");
61 this._inProgressLayer =
62 document.getElementById(
"playqueue-in-progress-layer-outer-box");
63 this._innerInProgressBox =
64 document.getElementById(
"playqueue-in-progress-layer-inner-box");
66 var playQueueService = Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
67 .getService(Ci.sbIPlayQueueService);
70 if (playQueueService.mediaList.isEmpty) {
71 this._showEmptyQueueLayer();
73 this._hideEmptyQueueLayer();
78 this._listListener = {
79 onItemAdded:
function(aList, aItem, aIndex) {
80 if (
self._listEmpty) {
81 self._hideEmptyQueueLayer();
84 onAfterItemRemoved:
function(aList, aItem, aIndex) {
86 self._showEmptyQueueLayer();
89 onListCleared:
function(aList) {
90 self._showEmptyQueueLayer();
94 playQueueService.mediaList.addListener(this._listListener,
96 Ci.sbIMediaList.LISTENER_FLAGS_ITEMADDED |
97 Ci.sbIMediaList.LISTENER_FLAGS_AFTERITEMREMOVED |
98 Ci.sbIMediaList.LISTENER_FLAGS_LISTCLEARED);
101 this._playQueueServiceListener = {
102 onIndexUpdated:
function(aToIndex) {
103 PlayQueueUtils.view.treeView.selection.tree.ensureRowIsVisible(aToIndex);
106 onQueueOperationStarted:
function() {
107 self._playlistBox.setAttribute(
"disabled",
"true");
108 self._messageLayer.setAttribute(
"hidden",
"true");
109 self._inProgressLayer.removeAttribute(
"hidden");
112 onQueueOperationCompleted:
function() {
113 self._playlistBox.removeAttribute(
"disabled");
114 self._messageLayer.setAttribute(
"hidden",
"true");
115 self._inProgressLayer.setAttribute(
"hidden",
"true");
119 playQueueService.addListener(this._playQueueServiceListener);
123 var sbWindow = Cc[
"@mozilla.org/appshell/window-mediator;1"]
124 .getService(Ci.nsIWindowMediator)
125 .getMostRecentWindow(
"Songbird:Main").window;
126 sbWindow.addEventListener(
"ShowCurrentTrack", this.onShowCurrentTrack,
true);
131 var mediacoreManager = Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
132 .getService(Ci.sbIMediacoreManager);
134 this._remoteShuffleDisabled =
137 this._mediacoreListener = {
138 onMediacoreEvent:
function (ev) {
139 if (ev.type == Ci.sbIMediacoreEvent.VIEW_CHANGE &&
142 mediacoreManager.sequencer.mode =
143 Ci.sbIMediacoreSequencer.MODE_FORWARD;
144 self._remoteShuffleDisabled.boolValue =
true;
149 mediacoreManager.addListener(this._mediacoreListener);
155 onUnload:
function playQueue_onUnload() {
158 var playQueueService = Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
159 .getService(Ci.sbIPlayQueueService);
161 if (this._listListener) {
162 playQueueService.mediaList.removeListener(this._listListener);
163 this._listListener =
null;
165 if (this._playQueueServiceListener) {
166 playQueueService.removeListener(this._playQueueServiceListener);
167 this._playQueueServiceListener =
null;
169 if (this._playlist) {
170 this._playlist.destroy();
171 this._playlist =
null;
175 var sbWindow = Cc[
"@mozilla.org/appshell/window-mediator;1"]
176 .getService(Ci.nsIWindowMediator)
177 .getMostRecentWindow(
"Songbird:Main").window;
179 sbWindow.removeEventListener(
"ShowCurrentTrack",
180 this.onShowCurrentTrack,
183 if (this._mediacoreListener) {
184 var mediacoreManager = Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
185 .getService(Ci.sbIMediacoreManager);
187 mediacoreManager.removeListener(this._mediacoreListener);
188 this._mediacoreListener =
null;
191 if(this._remoteShuffleDisabled) {
192 this._remoteShuffleDisabled.unbind();
193 this._remoteShuffleDisabled =
null;
201 _showEmptyQueueLayer:
function playQueue__showEmptyQueueLayer() {
203 this._playlistBox.setAttribute(
"disabled",
"true");
204 this._listEmpty =
true;
205 this._messageLayer.removeAttribute(
"hidden");
206 this._inProgressLayer.setAttribute(
"hidden",
"true");
212 _hideEmptyQueueLayer:
function playQueue__hideEmptyQueueLayer() {
214 this._playlistBox.removeAttribute(
"disabled");
215 this._messageLayer.setAttribute(
"hidden",
"true");
216 this._inProgressLayer.setAttribute(
"hidden",
"true");
217 this._listEmpty =
false;
228 onEmptyQueueDragEnter:
229 function playQueue_onEmptyQueueDragEnter(aEvent) {
232 if (this._playlist._canDrop(aEvent)) {
233 this._playlistBox.removeAttribute(
"disabled");
234 this._innerMessageBox.setAttribute(
"hidden",
"true");
245 onEmptyQueueDragExit:
246 function playQueue_onEmptyQueueDragExit(aEvent) {
249 this._playlistBox.setAttribute(
"disabled",
"true");
250 this._innerMessageBox.removeAttribute(
"hidden");
257 onEmptyQueueDragDrop:
258 function playQueue_onEmptyQueueDragDrop(aEvent) {
261 var dragService = Cc[
"@mozilla.org/widget/dragservice;1"]
262 .getService(Ci.nsIDragService);
263 var
session = dragService.getCurrentSession();
267 if (this._playlist._canDrop()) {
268 this._playlist._dropOnTree(this._playlist.mediaListView.length,
269 Ci.sbIMediaListViewTreeViewObserver.DROP_AFTER,
275 aEvent.stopPropagation();
281 onQueueInProgressDragOver:
282 function playQueue_onQueueInProgressDragOver(aEvent) {
284 aEvent.dataTransfer.effectAllowed =
"none";
285 aEvent.stopPropagation();
293 function playQueue_onShowCurrentTrack(aEvent) {
294 var mediacoreManager = Cc[
'@songbirdnest.com/Songbird/Mediacore/Manager;1']
295 .getService(Ci.sbIMediacoreManager);
296 var item = mediacoreManager.sequencer.currentItem;
298 var playQueueService = Cc[
"@songbirdnest.com/Songbird/playqueue/service;1"]
299 .getService(Ci.sbIPlayQueueService);
303 if (playQueueService.mediaList.contains(item)) {
306 var view = mediacoreManager.sequencer.view;
307 var row = mediacoreManager.sequencer.viewPosition;
308 view.selection.selectOnly(row);
309 view.treeView.selection.tree.ensureRowIsVisible(row);
310 aEvent.preventDefault();
311 aEvent.stopPropagation();
return!aWindow arguments!aWindow arguments[0]
function onUnload()
onUnload - called when the cover preview window unloads.