mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 08:28:01 +01:00
Added some media mappings, edited the getAlbums() function, renamed :playmedia to :filter and context titles in autocompletions
This commit is contained in:
@@ -1393,11 +1393,20 @@ function Completion() //{{{
|
|||||||
song: function song(context, args)
|
song: function song(context, args)
|
||||||
{
|
{
|
||||||
if (args.completeArg == 0)
|
if (args.completeArg == 0)
|
||||||
|
{
|
||||||
|
context.title = ["Artists"];
|
||||||
context.completions = getArtists();
|
context.completions = getArtists();
|
||||||
|
}
|
||||||
else if (args.completeArg == 1)
|
else if (args.completeArg == 1)
|
||||||
|
{
|
||||||
|
context.title = ["Albums by "+args[0]];
|
||||||
context.completions = getAlbums(args[0]);
|
context.completions = getAlbums(args[0]);
|
||||||
|
}
|
||||||
else if (args.completeArg == 2)
|
else if (args.completeArg == 2)
|
||||||
|
{
|
||||||
|
context.title = ["Tracks from "+args[1]+" by "+args[0]];
|
||||||
context.completions = getTracks(args[0],args[1]);
|
context.completions = getTracks(args[0],args[1]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
buffer: function buffer(context)
|
buffer: function buffer(context)
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ function Player() // {{{
|
|||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["l"], "Play Media",
|
["f"], "Filter Library",
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
commandline.open(":", "playmedia ", modes.EX);
|
commandline.open(":", "filter ", modes.EX);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
@@ -88,12 +88,52 @@ function Player() // {{{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
mappings.add([modes.PLAYER],
|
||||||
|
["h"], "Seek -10s",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
if (gMM.playbackControl.position >= 10000)
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.position - 10000;
|
||||||
|
else
|
||||||
|
gMM.playbackControl.position = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["l"], "Seek +10s",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
if ((gMM.playbackControl.duration - gMM.playbackControl.position) >= 10000)
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.position + 10000;
|
||||||
|
else
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.duration;
|
||||||
|
});
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["H"], "Seek -1m",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
if (gMM.playbackControl.position >= 60000)
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.position - 60000;
|
||||||
|
else
|
||||||
|
gMM.playbackControl.position = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["L"], "Seek +1m",
|
||||||
|
function ()
|
||||||
|
{
|
||||||
|
if ((gMM.playbackControl.duration - gMM.playbackControl.position) >= 60000)
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.position + 60000;
|
||||||
|
else
|
||||||
|
gMM.playbackControl.position = gMM.playbackControl.duration;
|
||||||
|
});
|
||||||
|
|
||||||
|
////////////////// ///////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
commands.add(["playmedia"],
|
commands.add(["f[ilter]"],
|
||||||
"Play Media",
|
"Filter Tracks",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
//Store the old view
|
//Store the old view
|
||||||
@@ -105,20 +145,17 @@ function Player() // {{{
|
|||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
|
|
||||||
//args
|
//args
|
||||||
if (args.length == 1)
|
switch (args.length)
|
||||||
{
|
{
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
case 3:
|
||||||
}
|
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
||||||
else if (args.length == 2)
|
case 2:
|
||||||
{
|
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
case 3:
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
||||||
}
|
break;
|
||||||
else if (args.length == 3)
|
default:
|
||||||
{
|
break;
|
||||||
customProps.appendProperty(SBProperties.artistName,args[0].toString());
|
|
||||||
customProps.appendProperty(SBProperties.albumName,args[1].toString());
|
|
||||||
customProps.appendProperty(SBProperties.trackName,args[2].toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0,Ci.sbIMediaItem)));
|
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0,Ci.sbIMediaItem)));
|
||||||
@@ -127,7 +164,7 @@ function Player() // {{{
|
|||||||
completer: function (context, args) completion.song(context, args)
|
completer: function (context, args) completion.song(context, args)
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}} }
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
@@ -179,17 +216,29 @@ function getArtistsArray()
|
|||||||
function getAlbums(artist)
|
function getAlbums(artist)
|
||||||
{
|
{
|
||||||
var list = LibraryUtils.mainLibrary;
|
var list = LibraryUtils.mainLibrary;
|
||||||
var albumArray = [];
|
var albumArray = [], returnArray = [];
|
||||||
var items = list.getItemsByProperty(SBProperties.artistName, artist).enumerate();
|
var items = list.getItemsByProperty(SBProperties.artistName, artist).enumerate();
|
||||||
var i = 0;
|
var i = 0, j = 0;
|
||||||
|
|
||||||
|
|
||||||
while (items.hasMoreElements()) {
|
while (items.hasMoreElements()) {
|
||||||
album = items.getNext().getProperty(SBProperties.albumName);
|
album = items.getNext().getProperty(SBProperties.albumName);
|
||||||
albumArray[i] = [album, album];
|
albumArray[i] = [album, album];
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
returnArray[j] = albumArray[i];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
else if (albumArray[i-1].toString() != albumArray[i].toString())
|
||||||
|
{
|
||||||
|
returnArray[i] = albumArray[i];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return util.Array.uniq(albumArray.map(String));
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTracks(artist,album)
|
function getTracks(artist,album)
|
||||||
|
|||||||
Reference in New Issue
Block a user