tmus

TUI Music Player
git clone https://git.sinitax.com/sinitax/tmus
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

commit 7146f1c08cf06c5865181f6e45b70505ca89d7a2
parent d1bc729d9a527817e505a2d5c40c5b1a745f9eec
Author: Louis Burda <quent.burda@gmail.com>
Date:   Sun, 10 Mar 2024 14:34:07 +0100

Update to new mplay status line format

Diffstat:
Msrc/player_mplay.c | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/player_mplay.c b/src/player_mplay.c @@ -222,9 +222,10 @@ player_update(void) } else if (!strncmp(tok, "pause=", 6)) { player.state = atoi(tok + 6) ? PLAYER_STATE_PAUSED : PLAYER_STATE_PLAYING; - } else if (!strncmp(tok, "time=", 5)) { - player.time_pos = atoi(tok + 5); - player.time_end = MAX(player.time_pos, player.time_end); + } else if (!strncmp(tok, "pos=", 4)) { + player.time_pos = atoi(tok + 4); + } else if (!strncmp(tok, "end=", 4)) { + player.time_end = atoi(tok + 4); } tok = strchr(tok, ','); if (!tok) break; @@ -268,16 +269,21 @@ player_clear_track(void) int player_toggle_pause(void) { - char *line; + char *line, *arg; fputc(MPLAY_ACTION_KEY_PAUSE, mplay.stdin); line = mplay_readline(); - if (!line || strncmp(line, "+PAUSE:", 7)) { + if (!line || !(arg = mplay_info_arg(line, MPLAY_INFO_STR_PAUSE))) { mplay_kill(); MPLAY_STATUS(line); return PLAYER_ERR; } + if (atoi(arg)) + player.state = PLAYER_STATE_PAUSED; + else + player.state = PLAYER_STATE_PLAYING; + return PLAYER_OK; }