From 0eec3250509c290d7be0cec43b06cb621f2b71f8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 Oct 2013 06:49:56 +0000 Subject: tracklist: remove_track updates tracklist position We should not have the position point too far past the end of the list. This allows playback to start when we do "tl add" on an idle player after removing something from the tracklist. --- lib/dtas/tracklist.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb index 6856648..325db20 100644 --- a/lib/dtas/tracklist.rb +++ b/lib/dtas/tracklist.rb @@ -101,11 +101,15 @@ class DTAS::Tracklist # :nodoc: def remove_track(track_id) by_track_id = _track_id_map - if idx = by_track_id.delete(track_id) - @list[idx] = nil - @list.compact! - # TODO: what do we do with @pos (and the currently-playing track) + idx = by_track_id.delete(track_id) or return false + @list[idx] = nil + @list.compact! + len = @list.size + if @pos >= len + @pos = len == 0 ? TL_DEFAULTS["pos"] : len end + @goto_pos = @goto_pos = nil # TODO: reposition? + true end def go_to(track_id, offset_hhmmss = nil) -- cgit v1.2.3-24-ge0c7