From 06d341e4590766ca2cd0770590758d49dde7f7ba Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 1 Aug 2009 14:19:00 -0700 Subject: New addid method. --- libmpd/playlist.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libmpd') diff --git a/libmpd/playlist.rb b/libmpd/playlist.rb index 000f9c9..2b40ce4 100644 --- a/libmpd/playlist.rb +++ b/libmpd/playlist.rb @@ -17,6 +17,15 @@ module MPDPlaylist return send_request('add "%s"' % uri) end + # Adds the specified file to the playlist and returns the song id. + # An optional playlist position can be specified. + def addid(uri, position=nil) + command = 'addid "%s"' % uri + command << ' %s' % position if position + + return send_request(command).scan(/(?!Id: )\d+/).first.to_i + end + # Deletes a song from the playlist. def delete(songpos) return send_request('delete %s' % songpos) -- cgit v1.2.3-70-g09d2