[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] player: "tl remove" properly stops current track
From: |
Eric Wong |
Subject: |
[PATCH 2/3] player: "tl remove" properly stops current track |
Date: |
Thu, 10 Oct 2013 10:51:03 +0000 |
This simplifies the check for the current track and
won't attempt to compare track IDs not on the tracklist.
---
lib/dtas/player/client_handler.rb | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/lib/dtas/player/client_handler.rb
b/lib/dtas/player/client_handler.rb
index b9beee4..010f6eb 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -572,21 +572,16 @@ module DTAS::Player::ClientHandler # :nodoc:
when "remove"
track_id = msg.shift or return io.emit("ERR track_id not specified")
track_id = track_id.to_i
- cur = @tl.cur_track
+ @tl.remove_track(track_id) or return io.emit("MISSING")
# skip if we're removing the currently playing track
- if cur.object_id == track_id && @current &&
- @current.respond_to?(:infile) && @current.infile == cur
+ if @current && @current.respond_to?(:infile) &&
+ @current.infile.object_id == track_id
_tl_skip
end
-
- 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
+ # 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")
when "get"
res = @tl.get_tracks(msg.map! { |i| i.to_i })
res.map! { |tid, file| "#{tid}=#{file ? Shellwords.escape(file) : ''}" }
--
1.8.4