diff --git a/common/content/completion.js b/common/content/completion.js index d90b6bd4..7596362f 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1411,17 +1411,9 @@ 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; + context.title = ["Playlist", "Type"]; + context.keys = { text: "name", description: "type" }; + context.completions = player.getPlaylists(); }, buffer: function buffer(context) diff --git a/xulmus/content/player.js b/xulmus/content/player.js index 8687d91d..d5b083b7 100755 --- a/xulmus/content/player.js +++ b/xulmus/content/player.js @@ -207,33 +207,37 @@ function Player() // {{{ "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 = []; + let arg = args.literalArg; - 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("\\",""); - SBGetBrowser().loadMediaList(playlists[playlistNames.indexOf(playlist.toLowerCase())]); - focusTrack(_SBGetCurrentView().getItemByIndex(0)); + + liberator.echoerr("E475: Invalid argument: " + arg); } else { - //load main library if there are no args + // load main library if there are no args _SBShowMainLibrary(); } }, { - //args: - completer: function(context, args) completion.playlist(context, args) + argCount: "?", + completer: function(context, args) completion.playlist(context, args), + literal: 0 }); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -378,33 +382,30 @@ function Player() // {{{ getPlaylists: function getPlaylists() { - let libraryManager = Components.classes["@songbirdnest.com/Songbird/library/Manager;1"] - .getService(Components.interfaces.sbILibraryManager); - let mainLibrary = libraryManager.mainLibrary; + let mainLibrary = LibraryUtils.mainLibrary; let playlists = [mainLibrary]; - let playlistsArray = []; let listener = { onEnumerationBegin: function() { }, onEnumerationEnd: function() { }, 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); - playlistsArray.push(item.name); } 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; }, // Play track at 'row' in 'playlist' 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); } }; diff --git a/xulmus/locale/en-US/player.txt b/xulmus/locale/en-US/player.txt index ed7ecb01..f4baae92 100644 --- a/xulmus/locale/en-US/player.txt +++ b/xulmus/locale/en-US/player.txt @@ -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 "+". ________________________________________________________________________________ +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: