mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 00:32:27 +01:00
Added :load [playlist]<tab>, command for loading specified playlist (autocompleted)
This commit is contained in:
@@ -1409,6 +1409,21 @@ function Completion() //{{{
|
||||
}
|
||||
},
|
||||
|
||||
playlist: function playlist(context, args)
|
||||
{
|
||||
let playlists = Player().getPlaylists();
|
||||
let length = playlists.length;
|
||||
let playlistNames = [];
|
||||
|
||||
for (var i=0; i < length; i++)
|
||||
{
|
||||
playlistNames[i] = [playlists[i].name.toString(),playlists[i].name];
|
||||
}
|
||||
|
||||
context.title = ["Playlists"];
|
||||
context.completions = playlistNames;
|
||||
},
|
||||
|
||||
buffer: function buffer(context)
|
||||
{
|
||||
filter = context.filter.toLowerCase();
|
||||
|
||||
@@ -203,6 +203,37 @@ function Player() // {{{
|
||||
},
|
||||
{ argCount: "1" });
|
||||
|
||||
commands.add(["load"],
|
||||
"Load a playlist",
|
||||
function (args)
|
||||
{
|
||||
|
||||
if (args.length != 0)
|
||||
{
|
||||
//load the selected playlist/smart playlist
|
||||
let playlists = player.getPlaylists();
|
||||
let length = playlists.length;
|
||||
let playlistNames = [];
|
||||
|
||||
for (var i=0; i < length; i++)
|
||||
{
|
||||
playlistNames[i] = playlists[i].name.toLowerCase();
|
||||
}
|
||||
|
||||
let playlist = args.string.replace("\\","");
|
||||
SBGetBrowser().loadMediaList(playlists[playlistNames.indexOf(playlist.toLowerCase())]);
|
||||
focusTrack(_SBGetCurrentView().getItemByIndex(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
//load main library if there are no args
|
||||
_SBShowMainLibrary();
|
||||
}
|
||||
},
|
||||
{
|
||||
//args:
|
||||
completer: function(context, args) completion.playlist(context, args)
|
||||
});
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
Reference in New Issue
Block a user