command: add command "getvol"
Closes https://github.com/MusicPlayerDaemon/MPD/issues/979
This commit is contained in:
parent
08360e401d
commit
871bf3b88f
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
ver 0.23 (not yet released)
|
ver 0.23 (not yet released)
|
||||||
|
* protocol
|
||||||
|
- new command "getvol"
|
||||||
|
|
||||||
ver 0.22.1 (not yet released)
|
ver 0.22.1 (not yet released)
|
||||||
* output
|
* output
|
||||||
|
|
|
@ -522,6 +522,16 @@ Playback options
|
||||||
Sets volume to ``VOL``, the range of
|
Sets volume to ``VOL``, the range of
|
||||||
volume is 0-100.
|
volume is 0-100.
|
||||||
|
|
||||||
|
:command:`getvol`
|
||||||
|
|
||||||
|
Read the volume. The result is a ``volume:`` line like in
|
||||||
|
:ref:`status <command_status>`. If there is no mixer, MPD will
|
||||||
|
emit an empty response. Example::
|
||||||
|
|
||||||
|
getvol
|
||||||
|
volume: 42
|
||||||
|
OK
|
||||||
|
|
||||||
:command:`single {STATE}` [#since_0_15]_
|
:command:`single {STATE}` [#since_0_15]_
|
||||||
Sets single state to ``STATE``,
|
Sets single state to ``STATE``,
|
||||||
``STATE`` should be ``0``, ``1`` or ``oneshot`` [#since_0_20]_.
|
``STATE`` should be ``0``, ``1`` or ``oneshot`` [#since_0_20]_.
|
||||||
|
|
|
@ -113,6 +113,7 @@ static constexpr struct command commands[] = {
|
||||||
#ifdef ENABLE_CHROMAPRINT
|
#ifdef ENABLE_CHROMAPRINT
|
||||||
{ "getfingerprint", PERMISSION_READ, 1, 1, handle_getfingerprint },
|
{ "getfingerprint", PERMISSION_READ, 1, 1, handle_getfingerprint },
|
||||||
#endif
|
#endif
|
||||||
|
{ "getvol", PERMISSION_READ, 0, 0, handle_getvol },
|
||||||
{ "idle", PERMISSION_READ, 0, -1, handle_idle },
|
{ "idle", PERMISSION_READ, 0, -1, handle_idle },
|
||||||
{ "kill", PERMISSION_ADMIN, -1, -1, handle_kill },
|
{ "kill", PERMISSION_ADMIN, -1, -1, handle_kill },
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
|
|
|
@ -318,6 +318,18 @@ handle_rescan(Client &client, Request args, Response &r)
|
||||||
return handle_update(client, args, r, true);
|
return handle_update(client, args, r, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandResult
|
||||||
|
handle_getvol(Client &client, Request, Response &r)
|
||||||
|
{
|
||||||
|
auto &partition = client.GetPartition();
|
||||||
|
|
||||||
|
const auto volume = volume_level_get(partition.outputs);
|
||||||
|
if (volume >= 0)
|
||||||
|
r.Format("volume: %i\n", volume);
|
||||||
|
|
||||||
|
return CommandResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_setvol(Client &client, Request args, Response &r)
|
handle_setvol(Client &client, Request args, Response &r)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,9 @@ handle_update(Client &client, Request request, Response &response);
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_rescan(Client &client, Request request, Response &response);
|
handle_rescan(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
|
CommandResult
|
||||||
|
handle_getvol(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_setvol(Client &client, Request request, Response &response);
|
handle_setvol(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue