aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-08 20:33:50 +0200
committerMax Kellermann <max@duempel.org>2009-10-08 20:33:50 +0200
commita5960c20cc679132e049fc6da0f3d7d6fa34e361 (patch)
treecdd21166134a5621690c024ca89c7c19a4001f74 /src/playlist_control.c
parentaa71ce4cd58bd38ca3798d29ef3e05df07280ae7 (diff)
downloadmpd-a5960c20cc679132e049fc6da0f3d7d6fa34e361.tar.gz
mpd-a5960c20cc679132e049fc6da0f3d7d6fa34e361.tar.xz
mpd-a5960c20cc679132e049fc6da0f3d7d6fa34e361.zip
playlist_control: "previous" really plays the previous song
No more CD player emulation. The current behaviour of "previous" is difficult for a client to predict, because it does not definitely know the current position within the song. If a client wants to restart the current song, it can always send "playid".
Diffstat (limited to '')
-rw-r--r--src/playlist_control.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/src/playlist_control.c b/src/playlist_control.c
index cfbcd19f1..16f4d5738 100644
--- a/src/playlist_control.c
+++ b/src/playlist_control.c
@@ -30,14 +30,6 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "playlist"
-enum {
- /**
- * When the "prev" command is received, rewind the current
- * track if this number of seconds has already elapsed.
- */
- PLAYLIST_PREV_UNLESS_ELAPSED = 10,
-};
-
void playlist_stop(struct playlist *playlist)
{
if (!playlist->playing)
@@ -191,29 +183,21 @@ void playlist_previous(struct playlist *playlist)
if (!playlist->playing)
return;
- if (g_timer_elapsed(playlist->prev_elapsed, NULL) >= 1.0 &&
- getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) {
- /* re-start playing the current song (just like the
- "prev" button on CD players) */
+ assert(queue_length(&playlist->queue) > 0);
- playlist_play_order(playlist, playlist->current);
+ if (playlist->current > 0) {
+ /* play the preceding song */
+ playlist_play_order(playlist,
+ playlist->current - 1);
+ } else if (playlist->queue.repeat) {
+ /* play the last song in "repeat" mode */
+ playlist_play_order(playlist,
+ queue_length(&playlist->queue) - 1);
} else {
- if (playlist->current > 0) {
- /* play the preceding song */
- playlist_play_order(playlist,
- playlist->current - 1);
- } else if (playlist->queue.repeat) {
- /* play the last song in "repeat" mode */
- playlist_play_order(playlist,
- queue_length(&playlist->queue) - 1);
- } else {
- /* re-start playing the current song if it's
- the first one */
- playlist_play_order(playlist, playlist->current);
- }
+ /* re-start playing the current song if it's
+ the first one */
+ playlist_play_order(playlist, playlist->current);
}
-
- g_timer_start(playlist->prev_elapsed);
}
enum playlist_result