Skip to content

Commit

Permalink
Fix: Pause streams with known duration #1371
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Nov 17, 2024
1 parent 332a13f commit 8999bfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

***

Expand Down
5 changes: 1 addition & 4 deletions htdocs/js/clickActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
32 changes: 19 additions & 13 deletions src/mympd_api/mympd_api_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 8999bfc

Please sign in to comment.