dtas-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] player: "tl remove" drops the track from the queue


From: Eric Wong
Subject: [PATCH 2/2] player: "tl remove" drops the track from the queue
Date: Wed, 9 Oct 2013 06:49:57 +0000

A paused/seeked track in the tracklist may end up in the queue.
---
 lib/dtas/player/client_handler.rb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/dtas/player/client_handler.rb 
b/lib/dtas/player/client_handler.rb
index f313a2a..b9beee4 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -580,7 +580,13 @@ def tl_handler(io, msg)
         _tl_skip
       end
 
-      io.emit(@tl.remove_track(track_id) ? "OK" : "MISSING")
+      if @tl.remove_track(track_id)
+        # drop it from the queue, too, in case it just got requeued or paused
+        @queue.delete_if { |t| Array === t && t[0].object_id == track_id }
+        io.emit("OK")
+      else
+        io.emit("MISSING")
+      end
     when "get"
       res = @tl.get_tracks(msg.map! { |i| i.to_i })
       res.map! { |tid, file| "#{tid}=#{file ? Shellwords.escape(file) : ''}" }
-- 
1.8.3.2.701.g8c4e4ec




reply via email to

[Prev in Thread] Current Thread [Next in Thread]