25 if (typeof(
Ci) ==
"undefined")
26 var
Ci = Components.interfaces;
27 if (typeof(
Cc) ==
"undefined")
28 var
Cc = Components.classes;
29 if (typeof(
Cr) ==
"undefined")
30 var
Cr = Components.results;
31 if (typeof(
Cu) ==
"undefined")
32 var
Cu = Components.utils;
35 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
36 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
37 Cu.import(
"resource://app/jsmodules/sbCoverHelper.jsm");
39 alert(
"lnNotifs: Unexpected error - module import error\n\n" + error)
49 lnNotifsService:
null,
53 var mainwindow =
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
54 .QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
55 .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
56 this.mmService = Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"].getService(Ci.sbIMediacoreManager);
57 this.strConv = Cc[
"@mozilla.org/intl/scriptableunicodeconverter"].getService(Ci.nsIScriptableUnicodeConverter);
58 this.lnNotifsService = Cc[
"@getnightingale.com/Nightingale/lnNotifs;1"].getService(Ci.ILNNotifs);
59 this.
wm = Cc[
"@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
60 this.
ios = Cc[
"@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
62 this.mainwindow = this.
wm.getMostRecentWindow(
"Songbird:Main");
63 var windowTitle = this.mainwindow.document.getElementById(
"mainplayer").getAttribute(
"title");
65 this.
prefs = Cc[
"@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch(
"extensions.libnotify-notifs.");
67 this.lnNotifsService.InitNotifs(windowTitle);
69 this.strConv.charset =
'utf-8';
70 var mm = this.mmService;
73 this.mmService.addListener({
74 onMediacoreEvent:
function(
event) {
76 if (that.mmService.sequencer.view ==
null)
return;
78 if (
event.type == Ci.sbIMediacoreEvent.TRACK_CHANGE) {
80 var notifsEnabled =
lnNotifs.prefs.getBoolPref(
"enableNotifications");
83 var curItem = that.mmService.sequencer.currentItem;
85 if (that.lastItem == curItem)
return;
86 else that.lastItem = curItem;
88 var resourceURL = curItem.getProperty(SBProperties.primaryImageURL);
92 fileURI = that.ios.newURI(decodeURI(resourceURL),
null,
null).QueryInterface(Ci.nsIFileURL).file.path;
99 var
artist = that.strConv.ConvertFromUnicode(curItem.getProperty(SBProperties.artistName));
100 var album = that.strConv.ConvertFromUnicode(curItem.getProperty(SBProperties.albumName));
101 var track = that.strConv.ConvertFromUnicode(curItem.getProperty(SBProperties.trackName));
102 var timeout = that.prefs.getIntPref(
"notificationTimeout");
104 that.lnNotifsService.TrackChangeNotify(track, artist, album, fileURI, timeout);
115 window.addEventListener(
"load",
function(e) {
lnNotifs.onLoad(); },
false);
116 window.addEventListener(
"unload",
function(e) {
lnNotifs.onUnload(); },
false);
var getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow('Songbird SBProperties artist
void EnableNotifications(in PRBool enable)
function onUnload()
onUnload - called when the cover preview window unloads.