mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-10 18:25:45 +01:00
Add a :seek command.
This commit is contained in:
@@ -11,21 +11,11 @@ function Player() // {{{
|
|||||||
// Get the focus to the visible playlist first
|
// Get the focus to the visible playlist first
|
||||||
//window._SBShowMainLibrary();
|
//window._SBShowMainLibrary();
|
||||||
|
|
||||||
// FIXME: need to test that we're playing - gMM.status.state
|
// interval (milliseconds)
|
||||||
// interval (seconds)
|
|
||||||
function seek(interval, direction)
|
function seek(interval, direction)
|
||||||
{
|
{
|
||||||
if (!gMM.playbackControl)
|
let position = gMM.playbackControl ? gMM.playbackControl.position : 0;
|
||||||
return;
|
player.seekTo(position + (direction ? interval : -interval));
|
||||||
|
|
||||||
interval = interval * 1000;
|
|
||||||
|
|
||||||
let min = 0;
|
|
||||||
let max = gMM.playbackControl.duration;
|
|
||||||
|
|
||||||
let position = gMM.playbackControl.position + (direction ? interval : -interval);
|
|
||||||
|
|
||||||
gMM.playbackControl.position = Math.min(Math.max(position, min), max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function focusTrack(mediaItem)
|
function focusTrack(mediaItem)
|
||||||
@@ -75,22 +65,22 @@ function Player() // {{{
|
|||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["h"], "Seek -10s",
|
["h"], "Seek -10s",
|
||||||
function (count) { player.seekBackward(Math.max(1, count) * 10); },
|
function (count) { player.seekBackward(Math.max(1, count) * 10000); },
|
||||||
{ flags: Mappings.flags.COUNT });
|
{ flags: Mappings.flags.COUNT });
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["l"], "Seek +10s",
|
["l"], "Seek +10s",
|
||||||
function (count) { player.seekForward(Math.max(1, count) * 10); },
|
function (count) { player.seekForward(Math.max(1, count) * 10000); },
|
||||||
{ flags: Mappings.flags.COUNT });
|
{ flags: Mappings.flags.COUNT });
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["H"], "Seek -1m",
|
["H"], "Seek -1m",
|
||||||
function (count) { player.seekBackward(Math.max(1, count) * 60); },
|
function (count) { player.seekBackward(Math.max(1, count) * 60000); },
|
||||||
{ flags: Mappings.flags.COUNT });
|
{ flags: Mappings.flags.COUNT });
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["L"], "Seek +1m",
|
["L"], "Seek +1m",
|
||||||
function (count) { player.seekForward(Math.max(1, count) * 60); },
|
function (count) { player.seekForward(Math.max(1, count) * 60000); },
|
||||||
{ flags: Mappings.flags.COUNT });
|
{ flags: Mappings.flags.COUNT });
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
@@ -141,7 +131,7 @@ function Player() // {{{
|
|||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["F[ilter]"],
|
commands.add(["F[ilter]"],
|
||||||
"Filter tracks based on keywords {artist/album/track}",
|
"Filter tracks based on keywords {genre/artist/album/track}",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let library = LibraryUtils.mainLibrary;
|
let library = LibraryUtils.mainLibrary;
|
||||||
@@ -182,6 +172,44 @@ function Player() // {{{
|
|||||||
"Stop track",
|
"Stop track",
|
||||||
function () { player.stop(); });
|
function () { player.stop(); });
|
||||||
|
|
||||||
|
commands.add(["see[k]"],
|
||||||
|
"Seek to a track position",
|
||||||
|
function (args)
|
||||||
|
{
|
||||||
|
let arg = args[0];
|
||||||
|
|
||||||
|
// intentionally supports 999:99:99
|
||||||
|
if (!/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg))
|
||||||
|
{
|
||||||
|
liberator.echoerr("E475: Invalid argument: " + arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m])
|
||||||
|
|
||||||
|
if (/:/.test(arg))
|
||||||
|
{
|
||||||
|
let [seconds, minutes, hours] = arg.split(":").reverse();
|
||||||
|
hours = hours || 0;
|
||||||
|
var value = ms(seconds, "s") + ms(minutes, "m") + ms(hours, "h");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!/[smh]/.test(arg.substr(-1)))
|
||||||
|
arg += "s"; // default to seconds
|
||||||
|
|
||||||
|
value = ms(arg.substring(arg, arg.length - 1), arg.substr(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^[-+]/.test(arg))
|
||||||
|
arg[0] == "-" ? player.seekBackward(value) : player.seekForward(value)
|
||||||
|
else
|
||||||
|
player.seekTo(value)
|
||||||
|
|
||||||
|
},
|
||||||
|
{ argCount: "1" });
|
||||||
|
|
||||||
|
// TODO: maybe :vol! could toggle mute on/off? --djk
|
||||||
commands.add(["vol[ume]"],
|
commands.add(["vol[ume]"],
|
||||||
"Set the volume",
|
"Set the volume",
|
||||||
function (args)
|
function (args)
|
||||||
@@ -251,6 +279,7 @@ function Player() // {{{
|
|||||||
gMM.volumeControl.volume = value;
|
gMM.volumeControl.volume = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// FIXME: can't be called from non-media tabs since 840e78
|
||||||
play: function play()
|
play: function play()
|
||||||
{
|
{
|
||||||
// Check if there is any selection in place, else play first item of the visible view.
|
// Check if there is any selection in place, else play first item of the visible view.
|
||||||
@@ -326,7 +355,19 @@ function Player() // {{{
|
|||||||
seek(interval, false);
|
seek(interval, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
seekTo: function seekTo(position)
|
||||||
|
{
|
||||||
|
if (!gMM.playbackControl)
|
||||||
|
this.play();
|
||||||
|
|
||||||
|
let min = 0;
|
||||||
|
let max = gMM.playbackControl.duration - 5000; // TODO: 5s buffer like cmus desirable?
|
||||||
|
|
||||||
|
gMM.playbackControl.position = Math.min(Math.max(position, min), max);
|
||||||
|
},
|
||||||
|
|
||||||
// FIXME: 10% ?
|
// FIXME: 10% ?
|
||||||
|
// I think just general increments of say 0.05 might be better --djk
|
||||||
increaseVolume: function increaseVolume()
|
increaseVolume: function increaseVolume()
|
||||||
{
|
{
|
||||||
gMM.volumeControl.volume = gMM.volumeControl.volume * 1.1;
|
gMM.volumeControl.volume = gMM.volumeControl.volume * 1.1;
|
||||||
@@ -363,6 +404,7 @@ function Player() // {{{
|
|||||||
|
|
||||||
return tracksList;
|
return tracksList;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Use this for implementing "/" and "?". -ken
|
// TODO: Use this for implementing "/" and "?". -ken
|
||||||
searchTracks: function searchTracks(args)
|
searchTracks: function searchTracks(args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,29 +62,29 @@ ________________________________________________________________________________
|
|||||||
section:Filtering{nbsp}the{nbsp}library[filter,filtering]
|
section:Filtering{nbsp}the{nbsp}library[filter,filtering]
|
||||||
|
|
||||||
|f| |:f| |:filter|
|
|f| |:f| |:filter|
|
||||||
||:f[ilter] [a][artist][a] [a]{album}[a] [a]{track}[a]|| +
|
||:f[ilter] {artist} [a][album][a] [a][track][a]|| +
|
||||||
||f||
|
||f||
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Filter and play tracks. If only [a][artist][a] is specified then all tracks for
|
Filter and play tracks. If only {artist} is specified then all tracks for that
|
||||||
that artist are played in album order. If {album} is also specified then all
|
artist are played in album order. If [a][album][a] is also specified then all
|
||||||
tracks for that album are played. A specific track can be specified with
|
tracks for that album are played. A specific track can be specified with
|
||||||
{track}.
|
[a][track][a].
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|F| |:F| |:Filter|
|
|F| |:F| |:Filter|
|
||||||
||:F[ilter] {keywords}|| +
|
||:F[ilter] {keywords}|| +
|
||||||
||F||
|
||F||
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Filter and show the tracks as a view. The tracks are filtered by the {keywords}
|
Filter and show the tracks as a view. The tracks are filtered by the {keywords}
|
||||||
provided as arguments. This text search applies over the default filter properties,
|
provided as arguments. This text search applies over the default filter
|
||||||
namely: Genre, Artist, and Album.
|
properties, namely: Genre, Artist, Album and Track.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
section:Seeking{nbsp}to{nbsp}a{nbsp}track{nbsp}position[seeking]
|
section:Seeking{nbsp}to{nbsp}a{nbsp}track{nbsp}position[seeking]
|
||||||
|
|
||||||
|h|
|
|h|
|
||||||
||h||
|
||[count]h||
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Seek +10s.
|
Seek +10s.
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
@@ -111,6 +111,18 @@ Seek -1m.
|
|||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|:see]| |:seek|
|
||||||
|
||:see[k] {[HH:]MM:SS]}|| +
|
||||||
|
||:see[k] +{time[hms]} | -{time[hms]}|| +
|
||||||
|
________________________________________________________________________________
|
||||||
|
Seek to an absolute or relative position in a track. The position can be given
|
||||||
|
in seconds (s), minutes (m), or hours (h). If the unit is not specified then
|
||||||
|
seconds is assumed. The position is absolute unless the value is prefixed with
|
||||||
|
"-" or "+".
|
||||||
|
|
||||||
|
Positions may also be specified in [a][HH:]MM:SS[a] format.
|
||||||
|
________________________________________________________________________________
|
||||||
|
|
||||||
section:Adjusting{nbsp}the{nbsp}volume[volume]
|
section:Adjusting{nbsp}the{nbsp}volume[volume]
|
||||||
|
|
||||||
|+| |=|
|
|+| |=|
|
||||||
@@ -129,11 +141,11 @@ ________________________________________________________________________________
|
|||||||
|
|
||||||
|
|
||||||
|:vol| |:volume|
|
|:vol| |:volume|
|
||||||
||:vol[ume][!] [a][value][a]|| +
|
||:vol[ume] {value}|| +
|
||||||
||:vol[ume][!] +{value} | -{value}|| +
|
||:vol[ume] +{value} | -{value}|| +
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
Set the player volume. [a][value][a] can be an absolute value between 0 and
|
Set the player volume. {value} can be an absolute value between 0 and 100% or a
|
||||||
100% or a relative value if prefixed with "-" or "+".
|
relative value if prefixed with "-" or "+".
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
section:Managing{nbsp}playlists[playlists]
|
section:Managing{nbsp}playlists[playlists]
|
||||||
|
|||||||
Reference in New Issue
Block a user