diff options
author | Max Kellermann <max@duempel.org> | 2011-12-24 11:20:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-12-24 11:20:02 +0100 |
commit | 99949c8f6fad1e2ef6aec5b742c8048d67b8280c (patch) | |
tree | 24449ca309778f02f29fb943765dc3b39d192904 /src/playlist_control.c | |
parent | 78c4351e04629d701a3652da9af98b080fd9f2b8 (diff) | |
download | mpd-99949c8f6fad1e2ef6aec5b742c8048d67b8280c.tar.gz mpd-99949c8f6fad1e2ef6aec5b742c8048d67b8280c.tar.xz mpd-99949c8f6fad1e2ef6aec5b742c8048d67b8280c.zip |
command: new command "seekcur"
For simpler seeking within current song.
Diffstat (limited to '')
-rw-r--r-- | src/playlist_control.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/playlist_control.c b/src/playlist_control.c index 998294845..0dea7676a 100644 --- a/src/playlist_control.c +++ b/src/playlist_control.c @@ -262,3 +262,27 @@ playlist_seek_song_id(struct playlist *playlist, struct player_control *pc, return playlist_seek_song(playlist, pc, song, seek_time); } + +enum playlist_result +playlist_seek_current(struct playlist *playlist, struct player_control *pc, + float seek_time, bool relative) +{ + if (!playlist->playing) + return PLAYLIST_RESULT_NOT_PLAYING; + + if (relative) { + struct player_status status; + pc_get_status(pc, &status); + + if (status.state != PLAYER_STATE_PLAY && + status.state != PLAYER_STATE_PAUSE) + return PLAYLIST_RESULT_NOT_PLAYING; + + seek_time += (int)status.elapsed_time; + } + + if (seek_time < 0) + seek_time = 0; + + return playlist_seek_song(playlist, pc, playlist->current, seek_time); +} |