1 if (typeof(
Cc) ==
"undefined")
2 var
Cc = Components.classes;
3 if (typeof(
Ci) ==
"undefined")
4 var
Ci = Components.interfaces;
7 if (typeof(gMetrics) ==
"undefined")
8 var gMetrics = Cc[
"@songbirdnest.com/Songbird/Metrics;1"]
9 .createInstance(Ci.sbIMetrics);
14 if (typeof(songbirdMainWindow) ==
"undefined")
15 var songbirdMainWindow = Cc[
"@mozilla.org/appshell/window-mediator;1"]
16 .getService(Ci.nsIWindowMediator)
17 .getMostRecentWindow(
"Songbird:Main").window;
24 onEnumerationBegin:
function(list) {
25 FavouriteStreams.genres =
new Array();
26 return Ci.sbIMediaListEnumerationListener.CONTINUE;
28 onEnumeratedItem:
function(list, item) {
30 "chrome://shoutcast-radio/skin/invis-16x16.png");
31 var genre = item.getProperty(SBProperties.genre);
32 if (typeof(FavouriteStreams.genres[genre]) ==
"undefined") {
34 FavouriteStreams.updateGenre(genre);
36 return Ci.sbIMediaListEnumerationListener.CONTINUE;
38 onEnumerationEnd:
function(list, status) {
42 updateGenre :
function(genre) {
44 var stationList = ShoutcastRadio.getStationList(genre);
47 var ourFavourites = this.list.getItemsByProperty(SBProperties.genre,
50 for (var
i=0;
i<ourFavourites.length;
i++) {
51 var item = ourFavourites.queryElementAt(
i, Ci.sbIMediaItem);
52 for (var j=0; j<stationList.length; j++) {
54 item.getProperty(
SC_id))
56 var comment = stationList[j].getAttribute(
"ct");
63 updateComments :
function() {
64 this.list = document.getElementById(
"playlist").mediaListView.mediaList;
65 this.list.enumerateAllItems(this.listListener);
69 var pls = document.getElementById(
"playlist");
70 var list = pls.mediaListView.mediaList;
71 if (list.getProperty(SBProperties.customType) ==
"radio_favouritesList")
73 pls.addEventListener(
"PlaylistCellClick", this.myCellClick,
false);
76 FavouriteStreams.oldOnPlay = songbirdMainWindow
77 .gSongbirdPlayerWindow.onPlay;
78 window.addEventListener(
"unload",
function() {
79 songbirdMainWindow.gSongbirdPlayerWindow.onPlay =
80 FavouriteStreams.oldOnPlay;
82 songbirdMainWindow.gSongbirdPlayerWindow.onPlay =
function() {};
84 pls.addEventListener(
"Play", this.onPlay,
false);
85 this.updateComments();
89 myCellClick :
function(e) {
90 var prop = e.getData(
"property");
91 var item = e.getData(
"item");
93 #ifdef METRICS_ENABLED
95 gMetrics.metricsInc(
"shoutcast",
"favourites",
"removed");
99 document.getElementById(
"playlist").mediaListView.mediaList;
104 onPlay :
function(e) {
105 var item = document.getElementById(
"playlist").mediaListView
106 .selection.currentMediaItem;
107 var
id = item.getProperty(
SC_id);
108 var plsURL = ShoutcastRadio.getListenURL(
id);
109 var plsMgr = Cc[
"@songbirdnest.com/Songbird/PlaylistReaderManager;1"]
110 .getService(Ci.sbIPlaylistReaderManager);
111 var
listener = Cc[
"@songbirdnest.com/Songbird/PlaylistReaderListener;1"]
112 .createInstance(Ci.sbIPlaylistReaderListener);
113 var
ioService = Cc[
"@mozilla.org/network/io-service;1"]
114 .getService(Ci.nsIIOService);
118 var
libraryManager = Cc[
"@songbirdnest.com/Songbird/library/Manager;1"]
119 .getService(Ci.sbILibraryManager);
120 this.tempLib = libraryManager.getLibrary(libGuid.value);
121 a = this.tempLib.getItemsByProperty(
122 SBProperties.customType,
"radio_tempStreamList");
123 this.streamList = a.queryElementAt(0, Ci.sbIMediaList);
126 this.streamList.clear();
128 listener.playWhenLoaded =
true;
129 listener.observer = {
131 if (aTopic ==
"success") {
135 for (var
i=0;
i<list.length;
i++) {
136 listItem = list.getItemByIndex(
i);
138 listItem.setProperty(
SC_id,
id);
139 listItem.setProperty(SBProperties.outerGUID, item.guid);
148 #ifdef METRICS_ENABLED
150 gMetrics.metricsInc(
"shoutcast",
"station",
"total.played");
153 gMetrics.metricsInc(
"shoutcast",
"station",
"played." +
id.toString());
156 var genre = item.getProperty(SBProperties.genre);
157 gMetrics.metricsInc(
"shoutcast",
"genre",
"played." + genre);
161 plsURL = item.getProperty(SBProperties.contentURL);
164 plsMgr.loadPlaylist(uri, this.streamList,
null,
false, listener);
171 FavouriteStreams.onLoad();
const shoutcastTempLibGuid
return aWindow document documentElement getAttribute(aAttribute)||dimension
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe