diff --git a/CHANGELOG.md b/CHANGELOG.md index 27e283222..128ee67f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This is a small bug fix release. ### Changelog - Fix: Parse hh:mm:ss timestamps #1370 +- Fix: Pause streams with known duration #1371 *** diff --git a/htdocs/js/clickActions.js b/htdocs/js/clickActions.js index beec91d38..0c181c8d4 100644 --- a/htdocs/js/clickActions.js +++ b/htdocs/js/clickActions.js @@ -270,10 +270,7 @@ function seekRelative(offset) { function clickPlay() { switch(currentState.state) { case 'play': - if (settings.webuiSettings.footerPlaybackControls === 'stop' || - isStreamUri(currentSongObj.uri) === true) - { - //always stop streams + if (settings.webuiSettings.footerPlaybackControls === 'stop') { sendAPI("MYMPD_API_PLAYER_STOP", {}, null, false); } else { diff --git a/src/mympd_api/mympd_api_handler.c b/src/mympd_api/mympd_api_handler.c index 5ce138763..5e5a8c409 100644 --- a/src/mympd_api/mympd_api_handler.c +++ b/src/mympd_api/mympd_api_handler.c @@ -739,9 +739,26 @@ void mympd_api_handler(struct t_mympd_state *mympd_state, struct t_partition_sta mpd_run_clearerror(partition_state->conn); response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_clearerror", &rc); break; + case MYMPD_API_PLAYER_PLAY: + if (mympd_api_status_clear_error(partition_state, &response->data, request->cmd_id, request->id) == false) { + break; + } + mpd_run_play(partition_state->conn); + response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_play", &rc); + break; case MYMPD_API_PLAYER_PAUSE: - mpd_run_pause(partition_state->conn, true); - response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_pause", &rc); + case MYMPD_API_PLAYER_STOP: + if (request->cmd_id == MYMPD_API_PLAYER_STOP || + partition_state->song_duration <= 0) + { + // do not pause streams with unknown duration + mpd_run_stop(partition_state->conn); + response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_stop", &rc); + } + else { + mpd_run_pause(partition_state->conn, true); + response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_pause", &rc); + } break; case MYMPD_API_PLAYER_RESUME: if (mympd_api_status_clear_error(partition_state, &response->data, request->cmd_id, request->id) == false) { @@ -758,17 +775,6 @@ void mympd_api_handler(struct t_mympd_state *mympd_state, struct t_partition_sta mpd_run_next(partition_state->conn); response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_next", &rc); break; - case MYMPD_API_PLAYER_PLAY: - if (mympd_api_status_clear_error(partition_state, &response->data, request->cmd_id, request->id) == false) { - break; - } - mpd_run_play(partition_state->conn); - response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_play", &rc); - break; - case MYMPD_API_PLAYER_STOP: - mpd_run_stop(partition_state->conn); - response->data = mympd_respond_with_error_or_ok(partition_state, response->data, request->cmd_id, request->id, "mpd_run_stop", &rc); - break; case MYMPD_API_PLAYER_PLAY_SONG: if (json_get_uint_max(request->data, "$.params.songId", &uint_buf1, &parse_error) == true) { mpd_run_play_id(partition_state->conn, uint_buf1);