mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-24 19:33:43 +01:00
Added :Filter command for filtering the view, searchTracks() for searching inside a visible view and focusTrack().
This commit is contained in:
@@ -28,6 +28,11 @@ function Player() // {{{
|
|||||||
gMM.playbackControl.position = Math.min(Math.max(position, min), max);
|
gMM.playbackControl.position = Math.min(Math.max(position, min), max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusTrack(mediaItem)
|
||||||
|
{
|
||||||
|
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem));
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -56,6 +61,10 @@ function Player() // {{{
|
|||||||
["f"], "Filter Library",
|
["f"], "Filter Library",
|
||||||
function () { commandline.open(":", "filter ", modes.EX); });
|
function () { commandline.open(":", "filter ", modes.EX); });
|
||||||
|
|
||||||
|
mappings.add([modes.PLAYER],
|
||||||
|
["F"], "Loads current view filtered by the keywords",
|
||||||
|
function () { commandline.open(":", "Filter ", modes.EX); });
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["s"], "Toggle Shuffle",
|
["s"], "Toggle Shuffle",
|
||||||
function () { player.toggleShuffle(); });
|
function () { player.toggleShuffle(); });
|
||||||
@@ -124,12 +133,34 @@ function Player() // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0, Ci.sbIMediaItem)));
|
sqncr.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0, Ci.sbIMediaItem)));
|
||||||
|
player.focusPlayingTrack();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
completer: function (context, args) completion.song(context, args)
|
completer: function (context, args) completion.song(context, args)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commands.add(["F[ilter]"],
|
||||||
|
"Filter tracks based on keywords {artist/album/track}",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
let library = LibraryUtils.mainLibrary;
|
||||||
|
let myView = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args.string);
|
||||||
|
if (myView.length == 0)
|
||||||
|
liberator.echoerr("No Tracks matching the keywords");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SBGetBrowser().loadMediaList(LibraryUtils.mainLibrary, null, null, myView,
|
||||||
|
"chrome://songbird/content/mediapages/filtersPage.xul");
|
||||||
|
//TODO: make this focusTrack work ?
|
||||||
|
focusTrack(myView.getItemByIndex(0));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
argCount: "+",
|
||||||
|
// completer: function (context, args) completion.tracks(context, args);
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: better off as a single command, or cmus compatible E.g. :player-next? --djk
|
// TODO: better off as a single command, or cmus compatible E.g. :player-next? --djk
|
||||||
commands.add(["playerp[lay]"],
|
commands.add(["playerp[lay]"],
|
||||||
"Play track",
|
"Play track",
|
||||||
@@ -188,6 +219,7 @@ function Player() // {{{
|
|||||||
play: function play()
|
play: function play()
|
||||||
{
|
{
|
||||||
gMM.sequencer.playView(SBGetBrowser().currentMediaListView, 0);
|
gMM.sequencer.playView(SBGetBrowser().currentMediaListView, 0);
|
||||||
|
focusTrack(gMM.sequencer.currentItem);
|
||||||
},
|
},
|
||||||
|
|
||||||
stop: function stop()
|
stop: function stop()
|
||||||
@@ -208,6 +240,7 @@ function Player() // {{{
|
|||||||
togglePlayPause: function togglePlayPause()
|
togglePlayPause: function togglePlayPause()
|
||||||
{
|
{
|
||||||
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
||||||
|
SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(gMM.sequencer.currentItem));
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleShuffle: function toggleShuffle()
|
toggleShuffle: function toggleShuffle()
|
||||||
@@ -260,7 +293,45 @@ function Player() // {{{
|
|||||||
gMM.volumeControl.volume = 0.1;
|
gMM.volumeControl.volume = 0.1;
|
||||||
else
|
else
|
||||||
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
|
gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9;
|
||||||
|
},
|
||||||
|
|
||||||
|
focusPlayingTrack :function focusPlayingTrack()
|
||||||
|
{
|
||||||
|
focusTrack(gMM.sequencer.currentItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
listTracks: function listTracks(view)
|
||||||
|
{
|
||||||
|
//let myView = LibraryUtils.createStandardMediaListView(LibraryUtils.mainLibrary, args);
|
||||||
|
let length = view.length;
|
||||||
|
let tracksList = [];
|
||||||
|
|
||||||
|
for (var i=0; i < length; i++)
|
||||||
|
{
|
||||||
|
var mediaItem = view.getItemByIndex(i);
|
||||||
|
var trackName = mediaItem.getProperty(SBProperties.trackName);
|
||||||
|
var albumName = mediaItem.getProperty(SBProperties.albumName);
|
||||||
|
var artistName = mediaItem.getProperty(SBProperties.artistName);
|
||||||
|
|
||||||
|
tracksList[i] = [ trackName, "Album : "+albumName+" Artist : "+artistName ];
|
||||||
|
}
|
||||||
|
return tracksList;
|
||||||
|
},
|
||||||
|
//TODO: Use this for implementing "/" and "?". -ken
|
||||||
|
searchTracks: function searchTracks(args)
|
||||||
|
{
|
||||||
|
let currentView = _SBGetCurrentView();
|
||||||
|
let mediaItemList = currentView.mediaList;
|
||||||
|
let search = _getSearchString(currentView);
|
||||||
|
let searchString = "";
|
||||||
|
if (search != "")
|
||||||
|
searchString = args + " " + search;
|
||||||
|
else
|
||||||
|
searchString = args;
|
||||||
|
let myView = LibraryUtils.createStandardMediaListView(mediaItemList, searchString);
|
||||||
|
focusTrack(myView.getItemByIndex(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user