From 82d8f07eeada8d4e0e537f9ccc8b867100f68c6b Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Tue, 19 Nov 2019 20:48:43 +0100 Subject: [PATCH] Player: Only change volume and report a position if we are actually playing something. --- src/player.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/player.cpp b/src/player.cpp index 3fb9ec7..7f4286c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -463,12 +463,14 @@ void Player::set_volume(uint8_t vol, bool save) { } void Player::vol_up() { + if (!is_playing()) return; uint8_t vol = _volume + VOLUME_STEP; if (vol > VOLUME_MAX) vol=VOLUME_MAX; set_volume(vol); } void Player::vol_down() { + if (!is_playing()) return; uint8_t vol = _volume - VOLUME_STEP; if (vol < VOLUME_MIN) vol=VOLUME_MIN; set_volume(vol); @@ -755,6 +757,7 @@ String Player::json() { } String Player::position_json() { + if (!is_playing()) return "null"; DynamicJsonDocument json(200); json["_type"] = "position"; json["position"] = _current_play_position;