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".
This commit is contained in:
Max Kellermann 2009-10-08 20:33:50 +02:00
parent aa71ce4cd5
commit a5960c20cc
4 changed files with 13 additions and 39 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ ver 0.16 (20??/??/??)
- removed the deprecated "volume" command - removed the deprecated "volume" command
- added the "findadd" command - added the "findadd" command
- range support for "delete" - range support for "delete"
- "previous" really plays the previous song
* input: * input:
- lastfm: use metadata - lastfm: use metadata
* tags: * tags:

View File

@ -62,16 +62,12 @@ playlist_init(struct playlist *playlist)
playlist->queued = -1; playlist->queued = -1;
playlist->current = -1; playlist->current = -1;
playlist->prev_elapsed = g_timer_new();
} }
void void
playlist_finish(struct playlist *playlist) playlist_finish(struct playlist *playlist)
{ {
queue_finish(&playlist->queue); queue_finish(&playlist->queue);
g_timer_destroy(playlist->prev_elapsed);
} }
/** /**

View File

@ -81,13 +81,6 @@ struct playlist {
* This variable is only valid if #playing is true. * This variable is only valid if #playing is true.
*/ */
int queued; int queued;
/**
* This timer tracks the time elapsed since the last "prev"
* command. If that is less than one second ago, "prev" jumps
* to the previous song instead of rewinding the current song.
*/
GTimer *prev_elapsed;
}; };
/** the global playlist object */ /** the global playlist object */

View File

@ -30,14 +30,6 @@
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "playlist" #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) void playlist_stop(struct playlist *playlist)
{ {
if (!playlist->playing) if (!playlist->playing)
@ -191,13 +183,8 @@ void playlist_previous(struct playlist *playlist)
if (!playlist->playing) if (!playlist->playing)
return; return;
if (g_timer_elapsed(playlist->prev_elapsed, NULL) >= 1.0 && assert(queue_length(&playlist->queue) > 0);
getPlayerElapsedTime() > PLAYLIST_PREV_UNLESS_ELAPSED) {
/* re-start playing the current song (just like the
"prev" button on CD players) */
playlist_play_order(playlist, playlist->current);
} else {
if (playlist->current > 0) { if (playlist->current > 0) {
/* play the preceding song */ /* play the preceding song */
playlist_play_order(playlist, playlist_play_order(playlist,
@ -213,9 +200,6 @@ void playlist_previous(struct playlist *playlist)
} }
} }
g_timer_start(playlist->prev_elapsed);
}
enum playlist_result enum playlist_result
playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time) playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
{ {