From: Max Kellermann Date: Mon, 2 Nov 2009 19:57:38 +0000 (+0100) Subject: player_command: implement setup_seek() without a song object X-Git-Tag: release-0.16~36 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=21e02b8b9c98568dfa67308a4dc8e2fecdfeb0b2;p=ncmpc.git player_command: implement setup_seek() without a song object Get the current song id from mpd_status_get_song_id(). --- diff --git a/src/player_command.c b/src/player_command.c index 505d2fc..a366b2a 100644 --- a/src/player_command.c +++ b/src/player_command.c @@ -85,14 +85,11 @@ cancel_seek_timer(void) static bool setup_seek(struct mpdclient *c) { - const struct mpd_song *song; - - song = mpdclient_get_current_song(c); - if (song == NULL) + if (!mpdclient_is_playing(c)) return false; - if (seek_id != (int)mpd_song_get_id(song)) { - seek_id = mpd_song_get_id(song); + if (seek_id != (int)mpd_status_get_song_id(c->status)) { + seek_id = mpd_status_get_song_id(c->status); seek_target_time = mpd_status_get_elapsed_time(c->status); } diff --git a/src/screen.c b/src/screen.c index 5d6e409..d3a8265 100644 --- a/src/screen.c +++ b/src/screen.c @@ -158,12 +158,12 @@ update_progress_window(struct mpdclient *c, bool repaint) { unsigned elapsed, duration; - if (c->song != NULL && seek_id == (int)mpd_song_get_id(c->song)) + if (c->status == NULL) + elapsed = 0; + else if (seek_id >= 0 && seek_id == mpd_status_get_song_id(c->status)) elapsed = seek_target_time; - else if (c->status != NULL) - elapsed = mpd_status_get_elapsed_time(c->status); else - elapsed = 0; + elapsed = mpd_status_get_elapsed_time(c->status); duration = mpdclient_is_playing(c) ? mpd_status_get_total_time(c->status) diff --git a/src/status_bar.c b/src/status_bar.c index 00724e3..2e94499 100644 --- a/src/status_bar.c +++ b/src/status_bar.c @@ -134,8 +134,8 @@ status_bar_paint(struct status_bar *p, const struct mpd_status *status, char elapsed_string[32], duration_string[32]; /*checks the conf to see whether to display elapsed or remaining time */ - if (song != NULL && - seek_id == (int)mpd_song_get_id(song)) + if (seek_id >= 0 && + seek_id == mpd_status_get_song_id(status)) elapsedTime = seek_target_time; else if (options.display_remaining_time) elapsedTime = total_time -