1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
|
function Player() // {{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
let lastSearchString = "";
let lastSearchIndex = 0;
let lastSearchView = _SBGetCurrentView();
// Get the focus to the visible playlist first
//window._SBShowMainLibrary();
services.add("mediaPageManager", "@songbirdnest.com/Songbird/MediaPageManager;1", Ci.sbIMediaPageManager);
services.add("propertyManager","@songbirdnest.com/Songbird/Properties/PropertyManager;1", Ci.sbIPropertyManager);
// Register Callbacks for searching.
liberator.registerCallback("change", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchKeyPress(str); });
liberator.registerCallback("submit", modes.SEARCH_VIEW_FORWARD, function (str) { player.onSearchSubmit(str); });
liberator.registerCallback("cancel", modes.SEARCH_VIEW_FORWARD, function () { player.onSearchCancel(); });
// interval (milliseconds)
function seek(interval, direction)
{
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
player.seekTo(position + (direction ? interval : -interval));
}
function focusTrack(mediaItem)
{
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
}
var mediaCoreListener = {
onMediacoreEvent: function (event)
{
switch (event.type)
{
case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
liberator.log("Before track changed: " + event.data);
autocommands.trigger("TrackChangePre", { track: event.data });
break;
case Ci.sbIMediacoreEvent.TRACK_CHANGE:
autocommands.trigger("TrackChange", { track: event.data });
break;
case Ci.sbIMediacoreEvent.BEFORE_VIEW_CHANGE:
liberator.log("Before view changed: " + event.data);
autocommands.trigger("ViewChangePre", { view: event.data });
break;
case Ci.sbIMediacoreEvent.VIEW_CHANGE:
liberator.log("View changed: " + event.data);
autocommands.trigger("ViewChange", { view: event.data });
break;
case Ci.sbIMediacoreEvent.STREAM_START:
liberator.log("Track started: " + gMM.sequencer.currentItem);
autocommands.trigger("StreamStart", { track: gMM.sequencer.currentItem });
break;
case Ci.sbIMediacoreEvent.STREAM_PAUSE:
liberator.log("Track paused: " + gMM.sequencer.currentItem);
autocommands.trigger("StreamPause", { track: gMM.sequencer.currentItem });
break;
case Ci.sbIMediacoreEvent.STREAM_END:
liberator.log("Track ended: " + gMM.sequencer.currentItem);
autocommands.trigger("StreamEnd", { track: gMM.sequencer.currentItem });
break;
case Ci.sbIMediacoreEvent.STREAM_STOP:
liberator.log("Track stopped: " + gMM.sequencer.currentItem);
autocommands.trigger("StreamStop", { track: gMM.sequencer.currentItem });
break;
}
}
};
gMM.addListener(mediaCoreListener);
liberator.registerObserver("shutdown", function () {
gMM.removeListener(mediaCoreListener);
});
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
options.add(["repeat"],
"Set the playback repeat mode",
"number", 0,
{
setter: function (value) gMM.sequencer.repeatMode = value,
getter: function () gMM.sequencer.repeatMode,
completer: function (context) [
["0", "Repeat none"],
["1", "Repeat one"],
["2", "Repeat all"]
],
validator: Option.validateCompleter
});
options.add(["shuffle"],
"Play tracks in shuffled order",
"boolean", false,
{
setter: function (value) value ? gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE :
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD,
getter: function () gMM.sequencer.mode == gMM.sequencer.MODE_SHUFFLE
});
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// MAPPINGS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
mappings.add([modes.PLAYER],
["x"], "Play track",
function () { player.play(); });
mappings.add([modes.PLAYER],
["z"], "Previous track",
function () { player.previous(); });
mappings.add([modes.PLAYER],
["c"], "Pause/unpause track",
function () { player.togglePlayPause(); });
mappings.add([modes.PLAYER],
["b"], "Next track",
function () { player.next(); });
mappings.add([modes.PLAYER],
["v"], "Stop track",
function () { player.stop(); });
mappings.add([modes.PLAYER],
["Q"], "Queue tracks by artist/album/track",
function () { commandline.open(":", "queue ", modes.EX); });
mappings.add([modes.PLAYER],
["f"], "Loads current view filtered by the keywords",
function () { commandline.open(":", "filter ", modes.EX); });
mappings.add([modes.PLAYER],
["i"], "Select current track",
function () { gSongbirdWindowController.doCommand("cmd_find_current_track"); });
mappings.add([modes.PLAYER],
["s"], "Toggle shuffle",
function () { player.toggleShuffle(); });
mappings.add([modes.PLAYER],
["r"], "Toggle repeat",
function () { player.toggleRepeat(); });
mappings.add([modes.PLAYER],
["h", "<Left>"], "Seek -10s",
function (count) { player.seekBackward(Math.max(1, count) * 10000); },
{ flags: Mappings.flags.COUNT });
mappings.add([modes.PLAYER],
["l", "<Right>"], "Seek +10s",
function (count) { player.seekForward(Math.max(1, count) * 10000); },
{ flags: Mappings.flags.COUNT });
mappings.add([modes.PLAYER],
["H", "<S-Left>"], "Seek -1m",
function (count) { player.seekBackward(Math.max(1, count) * 60000); },
{ flags: Mappings.flags.COUNT });
mappings.add([modes.PLAYER],
["L", "<S-Right>"], "Seek +1m",
function (count) { player.seekForward(Math.max(1, count) * 60000); },
{ flags: Mappings.flags.COUNT });
mappings.add([modes.PLAYER],
["=", "+"], "Increase volume by 10%",
function () { player.increaseVolume(); });
mappings.add([modes.PLAYER],
["-"], "Decrease volume by 10%",
function () { player.decreaseVolume(); });
mappings.add([modes.PLAYER],
["/"], "Search forward for a track",
function (args) { commandline.open("/", "", modes.SEARCH_VIEW_FORWARD); });
mappings.add([modes.PLAYER],
["n"], "Find the next track",
function () { player.searchViewAgain(false);});
mappings.add([modes.PLAYER],
["N"], "Find the previous track",
function () { player.searchViewAgain(true);});
for (let i in util.range(0, 6))
{
let (rating = i) {
mappings.add([modes.PLAYER],
["<C-" + rating + ">"], "Rate the current media item " + rating,
function () { player.rateMediaItem(rating); });
}
}
////////////////// ///////////////////////////////////////////////////////////}}}
////////////////////// COMMANDS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
commands.add(["f[ilter]"],
"Filter tracks based on keywords {genre/artist/album/track}",
function (args)
{
let library = LibraryUtils.mainLibrary;
let view = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.literalArg);
if (view.length == 0)
liberator.echoerr("No Tracks matching the keywords");
else
{
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, view,
"chrome://songbird/content/mediapages/filtersPage.xul");
// TODO: make this focusTrack work ?
focusTrack(view.getItemByIndex(0));
}
},
{
argCount: "1",
literal: 0
//completer: function (context, args) completion.tracks(context, args);
});
commands.add(["load"],
"Load a playlist",
function (args)
{
let arg = args.literalArg;
if (arg)
{
// load the selected playlist/smart playlist
let playlists = player.getPlaylists();
for ([i, list] in Iterator(playlists))
{
if (util.compareIgnoreCase(arg, list.name) == 0)
{
SBGetBrowser().loadMediaList(playlists[i]);
focusTrack(_SBGetCurrentView().getItemByIndex(0));
return;
}
}
liberator.echoerr("E475: Invalid argument: " + arg);
}
else
{
// load main library if there are no args
_SBShowMainLibrary();
}
},
{
argCount: "?",
completer: function (context, args) completion.playlist(context, args),
literal: 0
});
// TODO: better off as a single command (:player play) or cmus compatible (:player-play)? --djk
commands.add(["playerp[lay]"],
"Play track",
function () { player.play(); });
commands.add(["playerpa[use]"],
"Pause/unpause track",
function () { player.togglePlayPause(); });
commands.add(["playern[ext]"],
"Play next track",
function () { player.next(); });
commands.add(["playerpr[ev]"],
"Play previous track",
function () { player.previous(); });
commands.add(["players[top]"],
"Stop track",
function () { player.stop(); });
commands.add(["see[k]"],
"Seek to a track position",
function (args)
{
let arg = args[0];
// intentionally supports 999:99:99
if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
return void liberator.echoerr("E475: Invalid argument: " + arg);
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
if (/:/.test(arg))
{
let [seconds, minutes, hours] = arg.split(":").reverse();
hours = hours || 0;
var value = ms(seconds, "s") + ms(minutes, "m") + ms(hours, "h");
}
else
{
if (!/[smh]/.test(arg.substr(-1)))
arg += "s"; // default to seconds
value = ms(arg.substring(arg, arg.length - 1), arg.substr(-1));
}
if (/^[-+]/.test(arg))
arg[0] == "-" ? player.seekBackward(value) : player.seekForward(value)
else
player.seekTo(value)
},
{ argCount: "1" });
commands.add(["mediav[iew]"],
"Change the current media view",
function (args)
{
// FIXME: is this a SB restriction? --djk
if (!gBrowser.currentMediaPage)
return void liberator.echoerr("Exxx: Can only set the media view from the media tab"); // XXX
let arg = args[0];
if (arg)
{
let pages = player.getMediaPages();
for ([,page] in Iterator(pages))
{
if (util.compareIgnoreCase(arg, page.contentTitle) == 0)
{
player.loadMediaPage(page, gBrowser.currentMediaListView.mediaList, gBrowser.currentMediaListView);
return;
}
}
liberator.echoerr("E475: Invalid argument: " + arg);
}
},
{
argCount: "1",
completer: function (context) completion.mediaView(context),
literal: 0
});
commands.add(["sort[view]"],
"Sort the current media view",
function (args)
{
player.sortBy(args, true);
});
// FIXME: use :add -q like cmus? (not very vim-like are it's multi-option commands) --djk
commands.add(["qu[eue]"],
"Queue tracks by artist/album/track",
function (args)
{
// Store the old view
// let prev_view = gMM.status.view;
let library = LibraryUtils.mainLibrary;
let mainView = library.createView();
let customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
.createInstance(Ci.sbIMutablePropertyArray);
// args
switch (args.length)
{
case 3:
customProps.appendProperty(SBProperties.trackName, args[2]);
case 2:
customProps.appendProperty(SBProperties.albumName, args[1]);
case 1:
customProps.appendProperty(SBProperties.artistName, args[0]);
break;
default:
break;
}
gMM.sequencer.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0, Ci.sbIMediaItem)));
player.focusPlayingTrack();
},
{
argCount: "+",
completer: function (context, args) completion.song(context, args)
});
// TODO: maybe :vol! could toggle mute on/off? --djk
commands.add(["vol[ume]"],
"Set the volume",
function (args)
{
let arg = args[0];
if (!/^[+-]?\d+$/.test(arg))
return void liberator.echoerr("E488: Trailing characters");
let level = parseInt(arg, 10) / 100;
if (/^[+-]/.test(arg))
level = player.volume + level;
player.volume = util.Math.constrain(level, 0, 1);
},
{ argCount: "1" });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// COMPLETIONS /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
completion.song = function song(context, args) {
// TODO: useful descriptions?
function map(list) list.map(function (i) [i, ""]);
let [artist, album] = [args[0], args[1]];
if (args.completeArg == 0)
{
context.title = ["Artists"];
context.completions = map(library.getArtists());
}
else if (args.completeArg == 1)
{
context.title = ["Albums by " + artist];
context.completions = map(library.getAlbums(artist));
}
else if (args.completeArg == 2)
{
context.title = ["Tracks from " + album + " by " + artist];
context.completions = map(library.getTracks(artist, album));
}
};
completion.playlist = function playlist(context, args) {
context.title = ["Playlist", "Type"];
context.keys = { text: "name", description: "type" };
context.completions = player.getPlaylists();
};
completion.mediaView = function mediaView(context) {
context.title = ["Media View", "URL"];
context.anchored = false;
context.keys = { text: "contentTitle", description: "contentUrl" };
context.completions = player.getMediaPages();
};
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
return {
// TODO: check bounds and round, 0 - 1 or 0 - 100?
/**
* @property {string} The player volume as a percentage.
*/
get volume() gMM.volumeControl.volume,
set volume(value)
{
gMM.volumeControl.volume = value;
},
// FIXME: can't be called from non-media tabs since 840e78
play: function play()
{
// Check if there is any selection in place, else play first item of the visible view.
if (_SBGetCurrentView().selection.count != 0)
{
// Play the selection.
gMM.sequencer.playView(_SBGetCurrentView(), _SBGetCurrentView().getIndexForItem(_SBGetCurrentView().selection.currentMediaItem));
focusTrack(gMM.sequencer.currentItem);
}
else
{
gMM.sequencer.playView(SBGetBrowser().currentMediaListView, 0);
focusTrack(gMM.sequencer.currentItem);
}
},
stop: function stop()
{
gMM.sequencer.stop();
},
next: function next()
{
gSongbirdWindowController.doCommand("cmd_control_next");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
previous: function previous()
{
gSongbirdWindowController.doCommand("cmd_control_previous");
gSongbirdWindowController.doCommand("cmd_find_current_track");
},
togglePlayPause: function togglePlayPause()
{
gSongbirdWindowController.doCommand("cmd_control_playpause");
focusTrack(gMM.sequencer.currentItem);
},
toggleShuffle: function toggleShuffle()
{
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
else
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
},
// FIXME: not really toggling - good enough for now.
toggleRepeat: function toggleRepeat()
{
switch (gMM.sequencer.repeatMode)
{
case gMM.sequencer.MODE_REPEAT_NONE:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
break;
case gMM.sequencer.MODE_REPEAT_ONE:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
break;
case gMM.sequencer.MODE_REPEAT_ALL:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
break;
default:
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
break;
}
},
/**
* Seek forward <b>interval</b> milliseconds in the currently playing
* track.
*
* @param {number} interval The time interval (ms) to advance the
* current track.
*/
seekForward: function seekForward(interval)
{
seek(interval, true);
},
/**
* Seek backwards <b>interval</b> milliseconds in the currently
* playing track.
*
* @param {number} interval The time interval (ms) to rewind the
* current track.
*/
seekBackward: function seekBackward(interval)
{
seek(interval, false);
},
/**
* Seek to a specific position in the currently playing track.
*
* @param {number} The new position (ms) in the track.
*/
seekTo: function seekTo(position)
{
// FIXME: if not playing
if (!gMM.playbackControl)
this.play();
let min = 0;
let max = gMM.playbackControl.duration - 5000; // TODO: 5s buffer like cmus desirable?
gMM.playbackControl.position = util.Math.constrain(position, min, max);
},
// FIXME: 10% ?
// I think just general increments of say 0.05 might be better --djk
increaseVolume: function increaseVolume()
{
gMM.volumeControl.volume = gMM.volumeControl.volume * 1.1;
},
decreaseVolume: function decreaseVolume()
{
if (gMM.volumeControl.volume == 0)
gMM.volumeControl.volume = 0.1;
else
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
},
focusPlayingTrack :function focusPlayingTrack()
{
focusTrack(gMM.sequencer.currentItem);
},
listTracks: function listTracks(view)
{
//let myView = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args);
let length = view.length;
let tracksList = [];
for (let i = 0; i < length; i++)
{
let mediaItem = view.getItemByIndex(i);
let trackName = mediaItem.getProperty(SBProperties.trackName);
let albumName = mediaItem.getProperty(SBProperties.albumName);
let artistName = mediaItem.getProperty(SBProperties.artistName);
tracksList[i] = [trackName, "Album : " + albumName + " Artist : " + artistName];
}
return tracksList;
},
searchView: function searchView (args)
{
let currentView = _SBGetCurrentView();
let mediaItemList = currentView.mediaList;
let search = _getSearchString(currentView);
let searchString = "";
if (search != "")
searchString = args + " " + search;
else
searchString = args;
lastSearchString = searchString;
let mySearchView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
if (mySearchView.length)
{
lastSearchView = mySearchView;
lastSearchIndex = 0;
focusTrack(mySearchView.getItemByIndex(lastSearchIndex));
}
else
liberator.echoerr("E486 Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
},
searchViewAgain: function searchViewAgain(reverse)
{
function echo(str)
{
setTimeout(function () {
commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
}, 0);
}
if (reverse)
{
if (lastSearchIndex == 0)
{
lastSearchIndex = lastSearchView.length - 1;
echo("Search hit TOP, continuing at BOTTOM");
}
else
lastSearchIndex = lastSearchIndex - 1;
}
else
{
if (lastSearchIndex == (lastSearchView.length - 1))
{
lastSearchIndex = 0;
echo("Search hit BOTTOM, continuing at TOP");
}
else
lastSearchIndex = lastSearchIndex + 1;
}
// FIXME: Implement for "?" --ken
commandline.echo("/" + lastSearchString, null, commandline.FORCE_SINGLELINE);
focusTrack(lastSearchView.getItemByIndex(lastSearchIndex));
},
/**
* The search dialog keypress callback.
*
* @param {string} str The contents of the search dialog.
*/
onSearchKeyPress: function (str)
{
if (options["incsearch"])
this.searchView(str);
},
/**
* The search dialog submit callback.
*
* @param {string} str The contents of the search dialog.
*/
onSearchSubmit: function (str)
{
this.searchView(str);
},
/**
* The search dialog cancel callback.
*/
onSearchCancel: function ()
{
// TODO: restore the view state if altered by an 'incsearch' search
},
getPlaylists: function getPlaylists()
{
let mainLibrary = LibraryUtils.mainLibrary;
let playlists = [mainLibrary];
let listener = {
onEnumerationBegin: function () { },
onEnumerationEnd: function () { },
onEnumeratedItem: function (list, item)
{
// FIXME: why are there null items and duplicates?
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
playlists.push(item);
return Ci.sbIMediaListEnumerationListener.CONTINUE;
}
};
mainLibrary.enumerateItemsByProperty("http://songbirdnest.com/data/1.0#isList", "1", listener);
return playlists;
},
// Play track at 'row' in 'playlist'
playPlaylist: function playPlaylist(playlist, row)
{
gMM.sequencer.playView(playlist.createView(), row);
},
getMediaPages: function getMediaPages()
{
let list = gBrowser.currentMediaPage.mediaListView.mediaList;
let pages = services.get("mediaPageManager").getAvailablePages(list);
return ArrayConverter.JSArray(pages).map(function (page) page.QueryInterface(Ci.sbIMediaPageInfo));
},
loadMediaPage: function loadMediaList(page, list, view)
{
services.get("mediaPageManager").setPage(list, page);
gBrowser.loadMediaList(list, null, null, view, null);
},
rateMediaItem: function rateMediaItem(rating)
{
if (gMM.sequencer.currentItem)
gMM.sequencer.currentItem.setProperty(SBProperties.rating, rating);
},
getUserViewable: function getUserViewable()
{
let propManager = services.get("propertyManager");
let propEnumerator = propManager.propertyIDs;
let properties = [];
while (propEnumerator.hasMore())
{
let propertyID = propEnumerator.getNext();
if (propManager.getPropertyInfo(propertyID).userViewable)
{
liberator.dump("PropertyID - "+propManager.getPropertyInfo(propertyID).id);
properties.push(propManager.getPropertyInfo(propertyID).displayName);
}
}
return properties;
},
sortBy: function sortBy(property, order)
{
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
liberator.dump("Property: " + property);
switch (property.string)
{
case "#":
case "Title":
pa.appendProperty(SBProperties.trackName, "a");
break;
case "Rating":
pa.appendProperty(SBProperties.rating, 1);
break;
case "Album":
pa.appendProperty(SBProperties.albumName, "a");
break;
default:
pa.appendProperty(SBProperties.trackName, "a");
break;
}
_SBGetCurrentView().setSort(pa);
}
};
//}}}
} // }}}
// vim: set fdm=marker sw=4 ts=4 et:
|