1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-14 08:55:47 +01:00

Add new :volume command.

This commit is contained in:
Doug Kearns
2009-03-21 03:08:12 +11:00
parent 1423c78b02
commit 32292c9823
3 changed files with 66 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ Priority list:
1-9 as in Vim (9 = required for next release, 5 = would be nice, 1 = probably not) 1-9 as in Vim (9 = required for next release, 5 = would be nice, 1 = probably not)
BUGS: BUGS:
- SB doesn't support tab-undo yet so :undo and "u" etc don't work
FEATURES: FEATURES:
9 / and ? possibly reusing "Jump to" functionality directly. 9 / and ? possibly reusing "Jump to" functionality directly.

View File

@@ -11,10 +11,13 @@ 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 - why is gMM.playbackControl.status always null? // FIXME: need to test that we're playing - gMM.status.state
// interval (seconds) // interval (seconds)
function seek(interval, direction) function seek(interval, direction)
{ {
if (!gMM.playbackControl)
return;
interval = interval * 1000; interval = interval * 1000;
let min = 0; let min = 0;
@@ -127,7 +130,15 @@ function Player() // {{{
completer: function (context, args) completion.song(context, args) completer: function (context, args) completion.song(context, args)
}); });
// TODO: better of 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]"],
"Play track",
function () { player.play(); });
commands.add(["playerpa[use]"],
"Pause/unpause track",
function () { player.togglePlayPause(); });
commands.add(["playern[ext]"], commands.add(["playern[ext]"],
"Play next track", "Play next track",
function () { player.next(); }); function () { player.next(); });
@@ -140,13 +151,26 @@ function Player() // {{{
"Stop track", "Stop track",
function () { player.stop(); }); function () { player.stop(); });
commands.add(["playerp[lay]"], commands.add(["vol[ume]"],
"Play track", "Set the volume",
function () { player.play(); }); function (args)
{
let arg = args[0];
commands.add(["playerpa[use]"], if (!/^[+-]?\d+$/.test(arg))
"Pause/unpause track", {
function () { player.togglePlayPause(); }); liberator.echoerr("E488: Trailing characters");
return;
}
let level = parseInt(arg, 10) / 100;
if (/^[+-]/.test(arg))
level = player.volume + level;
player.volume = Math.min(Math.max(level, 0), 1);
},
{ argCount: 1 });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
@@ -154,6 +178,13 @@ function Player() // {{{
return { return {
// TODO: check bounds and round, 0 - 1 or 0 - 100?
get volume() gMM.volumeControl.volume,
set volume(value)
{
gMM.volumeControl.volume = value;
},
play: function play() play: function play()
{ {
gMM.sequencer.play(); gMM.sequencer.play();
@@ -209,14 +240,12 @@ function Player() // {{{
seekForward: function seekForward(interval) seekForward: function seekForward(interval)
{ {
if (gMM.playbackControl) seek(interval, true);
seek(interval, true);
}, },
seekBackward: function seekBackward(interval) seekBackward: function seekBackward(interval)
{ {
if (gMM.playbackControl) seek(interval, false);
seek(interval, false);
}, },
//FIXME: 10% ? //FIXME: 10% ?

View File

@@ -5,6 +5,8 @@ HEADER
The following features apply to Player mode which is activated when the media The following features apply to Player mode which is activated when the media
tab has focus. tab has focus.
section:Playing{nbsp}tracks[playing-tracks]
|x| |:playerp| |:playerplay| |x| |:playerp| |:playerplay|
||:playerp[lay]|| + ||:playerp[lay]|| +
||x|| ||x||
@@ -57,6 +59,20 @@ ________________________________________________________________________________
Toggle repeat mode. Toggle repeat mode.
________________________________________________________________________________ ________________________________________________________________________________
section:Filtering{nbsp}the{nbsp}library[filter,filtering]
|f| |:f| |:filter|
||:f[ilter] [a][artist][a] [a]{album}[a] [a]{track}[a]|| +
||f||
________________________________________________________________________________
Filter and play tracks. If only [a][artist][a] is specified then all tracks for
that artist are played in album order. If {album} is also specified then all
tracks for that album are played. A specific track can be specified with
{track}.
________________________________________________________________________________
section:Seeking{nbsp}to{nbsp}a{nbsp}track{nbsp}position[seeking]
|h| |h|
||h|| ||h||
@@ -86,6 +102,8 @@ Seek -1m.
________________________________________________________________________________ ________________________________________________________________________________
section:Adjusting{nbsp}the{nbsp}volume[volume]
|+| |=| |+| |=|
||+|| + ||+|| +
||=|| ||=||
@@ -93,6 +111,7 @@ ________________________________________________________________________________
Increase volume by 10%. Increase volume by 10%.
________________________________________________________________________________ ________________________________________________________________________________
|-| |-|
||-|| ||-||
________________________________________________________________________________ ________________________________________________________________________________
@@ -100,14 +119,12 @@ Decrease volume by 10%.
________________________________________________________________________________ ________________________________________________________________________________
|f| |:f| |:filter| |:vol| |:volume|
||:f[ilter] [a][artist][a] [a]{album}[a] [a]{track}[a]|| + ||:vol[ume][!] [a][value][a]|| +
||f|| ||:vol[ume][!] +{value} | -{value}|| +
________________________________________________________________________________ ________________________________________________________________________________
Filter and play tracks. If only [a][artist][a] is specified then all tracks for Set the player volume. [a][value][a] can be an absolute value between 0 and
that artist are played in album order. If {album} is also specified then all 100% or a relative value if prefixed with "-" or "+".
tracks for that album are played. A specific track can be specified with
{track}.
________________________________________________________________________________ ________________________________________________________________________________
// vim: set filetype=asciidoc: // vim: set filetype=asciidoc: