about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/dtas/player/client_handler.rb1
-rw-r--r--lib/dtas/tracklist.rb13
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index 17cd6c3..a27e4f5 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -312,6 +312,7 @@ module DTAS::Player::ClientHandler # :nodoc:
         h
       end
     end
+    tmp['tracklist'] = @tl.to_hsh(false)
     io.emit(tmp.to_yaml)
   end
 
diff --git a/lib/dtas/tracklist.rb b/lib/dtas/tracklist.rb
index 7366799..726a46a 100644
--- a/lib/dtas/tracklist.rb
+++ b/lib/dtas/tracklist.rb
@@ -13,7 +13,6 @@ class DTAS::Tracklist # :nodoc:
   attr_accessor :max # integer
 
   TL_DEFAULTS = {
-    'list' => [],
     'pos' => -1,
     'repeat' => false,
     'max' => 20_000,
@@ -24,7 +23,7 @@ class DTAS::Tracklist # :nodoc:
     obj = new
     obj.instance_eval do
       list = hash['list'] and @list.replace(list.map { |s| new_track(s) })
-      %w(pos repeat max).each do |k|
+      SIVS.each do |k|
         instance_variable_set("@#{k}", hash[k] || TL_DEFAULTS[k])
       end
 
@@ -39,10 +38,16 @@ class DTAS::Tracklist # :nodoc:
     obj
   end
 
-  def to_hsh
+  def to_hsh(full_list = true)
     h = ivars_to_hash(SIVS)
     h.delete_if { |k,v| TL_DEFAULTS[k] == v }
-    list = h['list'] and h['list'] = list.map(&:to_path)
+    unless @list.empty?
+      if full_list
+        h['list'] = @list.map(&:to_path)
+      else
+        h['size'] = @list.size
+      end
+    end
     if @shuffle
       h['shuffle'] = true
       h['pos'] = _idx_of(@list, @shuffle[@pos].track_id) if @pos >= 0