mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-20 02:25:46 +01:00
Fix and document :load.
This commit is contained in:
@@ -1411,17 +1411,9 @@ function Completion() //{{{
|
|||||||
|
|
||||||
playlist: function playlist(context, args)
|
playlist: function playlist(context, args)
|
||||||
{
|
{
|
||||||
let playlists = Player().getPlaylists();
|
context.title = ["Playlist", "Type"];
|
||||||
let length = playlists.length;
|
context.keys = { text: "name", description: "type" };
|
||||||
let playlistNames = [];
|
context.completions = player.getPlaylists();
|
||||||
|
|
||||||
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)
|
buffer: function buffer(context)
|
||||||
|
|||||||
@@ -207,33 +207,37 @@ function Player() // {{{
|
|||||||
"Load a playlist",
|
"Load a playlist",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
|
let arg = args.literalArg;
|
||||||
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++)
|
if (arg)
|
||||||
|
{
|
||||||
|
// load the selected playlist/smart playlist
|
||||||
|
let playlists = player.getPlaylists();
|
||||||
|
|
||||||
|
for ([i, list] in Iterator(playlists))
|
||||||
{
|
{
|
||||||
playlistNames[i] = playlists[i].name.toLowerCase();
|
if (util.compareIgnoreCase(arg, list.name) == 0)
|
||||||
|
{
|
||||||
|
SBGetBrowser().loadMediaList(playlists[i]);
|
||||||
|
focusTrack(_SBGetCurrentView().getItemByIndex(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let playlist = args.string.replace("\\","");
|
liberator.echoerr("E475: Invalid argument: " + arg);
|
||||||
SBGetBrowser().loadMediaList(playlists[playlistNames.indexOf(playlist.toLowerCase())]);
|
|
||||||
focusTrack(_SBGetCurrentView().getItemByIndex(0));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//load main library if there are no args
|
// load main library if there are no args
|
||||||
_SBShowMainLibrary();
|
_SBShowMainLibrary();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
//args:
|
argCount: "?",
|
||||||
completer: function(context, args) completion.playlist(context, args)
|
completer: function(context, args) completion.playlist(context, args),
|
||||||
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -378,33 +382,30 @@ function Player() // {{{
|
|||||||
|
|
||||||
getPlaylists: function getPlaylists()
|
getPlaylists: function getPlaylists()
|
||||||
{
|
{
|
||||||
let libraryManager = Components.classes["@songbirdnest.com/Songbird/library/Manager;1"]
|
let mainLibrary = LibraryUtils.mainLibrary;
|
||||||
.getService(Components.interfaces.sbILibraryManager);
|
|
||||||
let mainLibrary = libraryManager.mainLibrary;
|
|
||||||
let playlists = [mainLibrary];
|
let playlists = [mainLibrary];
|
||||||
let playlistsArray = [];
|
|
||||||
let listener = {
|
let listener = {
|
||||||
onEnumerationBegin: function() { },
|
onEnumerationBegin: function() { },
|
||||||
onEnumerationEnd: function() { },
|
onEnumerationEnd: function() { },
|
||||||
onEnumeratedItem: function(list, item)
|
onEnumeratedItem: function(list, item)
|
||||||
{
|
{
|
||||||
if (playlistsArray.indexOf(item.name) == -1)
|
// FIXME: why are there null items and duplicates?
|
||||||
|
if (!playlists.some(function (list) list.name == item.name) && item.name != null)
|
||||||
{
|
{
|
||||||
playlists.push(item);
|
playlists.push(item);
|
||||||
playlistsArray.push(item.name);
|
|
||||||
}
|
}
|
||||||
return Components.interfaces.sbIMediaListEnumerationListener.CONTINUE;
|
return Components.interfaces.sbIMediaListEnumerationListener.CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mainLibrary.enumerateItemsByProperty("http://songbirdnest.com/data/1.0#isList", "1", listener );
|
|
||||||
|
mainLibrary.enumerateItemsByProperty("http://songbirdnest.com/data/1.0#isList", "1", listener);
|
||||||
|
|
||||||
return playlists;
|
return playlists;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Play track at 'row' in 'playlist'
|
// Play track at 'row' in 'playlist'
|
||||||
playPlaylist: function playPlaylist(playlist, row)
|
playPlaylist: function playPlaylist(playlist, row)
|
||||||
{
|
{
|
||||||
let gMM = Components.classes["@songbirdnest.com/Songbird/Mediacore/Manager;1"]
|
|
||||||
.getService(Components.interfaces.sbIMediacoreManager);
|
|
||||||
gMM.sequencer.playView(playlist.createView(), row);
|
gMM.sequencer.playView(playlist.createView(), row);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -136,4 +136,13 @@ Set the player volume. [a][value][a] can be an absolute value between 0 and
|
|||||||
100% or a relative value if prefixed with "-" or "+".
|
100% or a relative value if prefixed with "-" or "+".
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
section:Managing{nbsp}playlists[playlists]
|
||||||
|
|
||||||
|
|:load|
|
||||||
|
||:load [a][playlist][a]|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
Load [a][playlist][a]. If no playlist is specified then the main library view
|
||||||
|
is loaded.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
// vim: set filetype=asciidoc:
|
// vim: set filetype=asciidoc:
|
||||||
|
|||||||
Reference in New Issue
Block a user