From df66dbd4594527ce5e6e8315c6775c9dbdd12dc1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Sep 2013 04:32:53 +0000 Subject: player/client_handler: "tl add" returns track_id of added track This allows easier scripting if we want to add a bunch of tracks --- lib/dtas/player/client_handler.rb | 4 ++-- lib/dtas/tracklist.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 2966193..7a63df1 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -527,7 +527,7 @@ module DTAS::Player::ClientHandler # :nodoc: return io.emit("ERR tl add PATH [after_track_id] [true|false]") end begin - @tl.add_track(path, after_track_id, set_as_current) + track_id = @tl.add_track(path, after_track_id, set_as_current) rescue ArgumentError => e return io.emit("ERR #{e.message}") end @@ -537,7 +537,7 @@ module DTAS::Player::ClientHandler # :nodoc: if @tl.size == 1 && !(@current || @queue[0] || @paused) next_source(path) end - io.emit("OK") + io.emit("#{track_id}") when "repeat" case msg.shift when "true" then @tl.repeat = true diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb index 2c4ad03..2336545 100644 --- a/lib/dtas/tracklist.rb +++ b/lib/dtas/tracklist.rb @@ -87,6 +87,7 @@ class DTAS::Tracklist @list.unshift(track) @pos = 0 if set_as_current end + track.object_id end def remove_track(track_id) -- cgit v1.2.3-24-ge0c7