mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-25 08:55:47 +01:00
Add Songbird specific services to the services module.
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
// Copyright (c) 2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||||
|
// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
|
||||||
|
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
@@ -195,7 +197,7 @@ const Config = Module("config", ConfigBase, {
|
|||||||
this.showServicePane(true);
|
this.showServicePane(true);
|
||||||
else {
|
else {
|
||||||
let pane = document.getElementById(id);
|
let pane = document.getElementById(id);
|
||||||
let manager = Cc['@songbirdnest.com/Songbird/DisplayPane/Manager;1'].getService(Ci.sbIDisplayPaneManager);
|
let manager = services.get("displayPaneManager");
|
||||||
let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue);
|
let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue);
|
||||||
|
|
||||||
if (!paneinfo)
|
if (!paneinfo)
|
||||||
@@ -300,6 +302,11 @@ const Config = Module("config", ConfigBase, {
|
|||||||
},
|
},
|
||||||
getter: function () !services.get("io").offline
|
getter: function () !services.get("io").offline
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
services: function () {
|
||||||
|
services.addClass("mutablePropertyArray", "@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1",
|
||||||
|
Ci.sbIMutablePropertyArray);
|
||||||
|
services.add("displayPaneManager", "@songbirdnest.com/Songbird/DisplayPane/Manager;1", Ci.sbIDisplayPaneManager);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
|
// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
|
||||||
|
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
@@ -9,7 +10,7 @@ const Library = Module("library", {
|
|||||||
this.MAIN_LIBRARY = LibraryUtils.mainLibrary;
|
this.MAIN_LIBRARY = LibraryUtils.mainLibrary;
|
||||||
},
|
},
|
||||||
|
|
||||||
_toJSArray: function (enum) ArrayConverter.JSArray(enum),
|
_toJSArray: function _toJSArray(enum) ArrayConverter.JSArray(enum),
|
||||||
|
|
||||||
// TODO: return some actually useful objects. ;-)
|
// TODO: return some actually useful objects. ;-)
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +43,7 @@ const Library = Module("library", {
|
|||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
getTracks: function getTracks(artist, album) {
|
getTracks: function getTracks(artist, album) {
|
||||||
const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
let properties = services.create("mutablePropertyArray");
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
|
||||||
|
|
||||||
properties.appendProperty(SBProperties.artistName, artist);
|
properties.appendProperty(SBProperties.artistName, artist);
|
||||||
properties.appendProperty(SBProperties.albumName, album);
|
properties.appendProperty(SBProperties.albumName, album);
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
|
// Copyright (c) 2009 by Prathyush Thota <prathyushthota@gmail.com>
|
||||||
|
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
|
|
||||||
|
|
||||||
const Player = Module("player", {
|
const Player = Module("player", {
|
||||||
init: function () {
|
init: function init() {
|
||||||
this._lastSearchString = "";
|
this._lastSearchString = "";
|
||||||
this._lastSearchIndex = 0;
|
this._lastSearchIndex = 0;
|
||||||
this._lastSearchView = _SBGetCurrentView();
|
this._lastSearchView = _SBGetCurrentView();
|
||||||
@@ -15,17 +16,17 @@ const Player = Module("player", {
|
|||||||
|
|
||||||
gMM.addListener(this._mediaCoreListener);
|
gMM.addListener(this._mediaCoreListener);
|
||||||
},
|
},
|
||||||
destroy: function () {
|
destroy: function destroy() {
|
||||||
gMM.removeListener(this._mediaCoreListener);
|
gMM.removeListener(this._mediaCoreListener);
|
||||||
},
|
},
|
||||||
|
|
||||||
// interval (milliseconds)
|
// interval (milliseconds)
|
||||||
_seek: function (interval, direction) {
|
_seek: function _seek(interval, direction) {
|
||||||
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
|
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
|
||||||
player.seekTo(position + (direction ? interval : -interval));
|
player.seekTo(position + (direction ? interval : -interval));
|
||||||
},
|
},
|
||||||
|
|
||||||
_focusTrack: function (mediaItem) {
|
_focusTrack: function _focusTrack(mediaItem) {
|
||||||
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
|
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ const Player = Module("player", {
|
|||||||
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
|
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
|
||||||
},
|
},
|
||||||
|
|
||||||
focusPlayingTrack :function focusPlayingTrack() {
|
focusPlayingTrack: function focusPlayingTrack() {
|
||||||
this._focusTrack(gMM.sequencer.currentItem);
|
this._focusTrack(gMM.sequencer.currentItem);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -264,7 +265,7 @@ const Player = Module("player", {
|
|||||||
*
|
*
|
||||||
* @param {string} str The contents of the search dialog.
|
* @param {string} str The contents of the search dialog.
|
||||||
*/
|
*/
|
||||||
onSearchKeyPress: function (str) {
|
onSearchKeyPress: function onSearchKeyPress(str) {
|
||||||
if (options["incsearch"])
|
if (options["incsearch"])
|
||||||
this.searchView(str);
|
this.searchView(str);
|
||||||
},
|
},
|
||||||
@@ -274,14 +275,14 @@ const Player = Module("player", {
|
|||||||
*
|
*
|
||||||
* @param {string} str The contents of the search dialog.
|
* @param {string} str The contents of the search dialog.
|
||||||
*/
|
*/
|
||||||
onSearchSubmit: function (str) {
|
onSearchSubmit: function onSearchSubmit(str) {
|
||||||
this.searchView(str);
|
this.searchView(str);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The search dialog cancel callback.
|
* The search dialog cancel callback.
|
||||||
*/
|
*/
|
||||||
onSearchCancel: function () {
|
onSearchCancel: function onSearchCancel() {
|
||||||
// TODO: restore the view state if altered by an 'incsearch' search
|
// TODO: restore the view state if altered by an 'incsearch' search
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -343,26 +344,25 @@ const Player = Module("player", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
sortBy: function sortBy(property, order) {
|
sortBy: function sortBy(property, order) {
|
||||||
let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray);
|
let properties = services.create("mutablePropertyArray");
|
||||||
liberator.dump("Property: " + property);
|
|
||||||
|
|
||||||
switch (property.string) {
|
switch (property.string) {
|
||||||
case "#":
|
case "#":
|
||||||
case "Title":
|
case "Title":
|
||||||
pa.appendProperty(SBProperties.trackName, "a");
|
properties.appendProperty(SBProperties.trackName, "a");
|
||||||
break;
|
break;
|
||||||
case "Rating":
|
case "Rating":
|
||||||
pa.appendProperty(SBProperties.rating, 1);
|
properties.appendProperty(SBProperties.rating, 1);
|
||||||
break;
|
break;
|
||||||
case "Album":
|
case "Album":
|
||||||
pa.appendProperty(SBProperties.albumName, "a");
|
properties.appendProperty(SBProperties.albumName, "a");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pa.appendProperty(SBProperties.trackName, "a");
|
properties.appendProperty(SBProperties.trackName, "a");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_SBGetCurrentView().setSort(pa);
|
_SBGetCurrentView().setSort(properties);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
}, {
|
}, {
|
||||||
@@ -518,23 +518,22 @@ const Player = Module("player", {
|
|||||||
// let prev_view = gMM.status.view;
|
// let prev_view = gMM.status.view;
|
||||||
let library = LibraryUtils.mainLibrary;
|
let library = LibraryUtils.mainLibrary;
|
||||||
let mainView = library.createView();
|
let mainView = library.createView();
|
||||||
let customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
let properties = services.create("mutablePropertyArray");
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
|
||||||
|
|
||||||
// args
|
// args
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 3:
|
case 3:
|
||||||
customProps.appendProperty(SBProperties.trackName, args[2]);
|
properties.appendProperty(SBProperties.trackName, args[2]);
|
||||||
case 2:
|
case 2:
|
||||||
customProps.appendProperty(SBProperties.albumName, args[1]);
|
properties.appendProperty(SBProperties.albumName, args[1]);
|
||||||
case 1:
|
case 1:
|
||||||
customProps.appendProperty(SBProperties.artistName, args[0]);
|
properties.appendProperty(SBProperties.artistName, args[0]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gMM.sequencer.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0, Ci.sbIMediaItem)));
|
gMM.sequencer.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(properties).queryElementAt(0, Ci.sbIMediaItem)));
|
||||||
player.focusPlayingTrack();
|
player.focusPlayingTrack();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user