lib/sonos/endpoint/a_v_transport.rb
# Add an Rdio object to the queue (album or track), anything else can only
# be streamed (play now).
# @param[Hash] opts Various options (album/track keys, username and type)
# @param[Integer] position Optional queue insertion position. Leaving this blank inserts at the end.
# @return[Integer] Queue position of the added track(s)
Add an Rdio object to the queue (album or track), anything else can only
be streamed (play now).
Add an Rdio object to the queue ( album or track ) anything else can only be streamed ( play now ) .
def add_rdio_to_queue(opts = {}, position = 0)
     opts = {
       :username => nil,
       :album    => nil,
       :track    => nil,
       :type     => 'track',
       :format   => 'mp3' 
     }.merge(opts)
     return nil if opts[:username].nil?
     return nil if opts[:album].nil?
     return nil if opts[:type] == 'track' and opts[:track].nil?
     opts[:track] = '' if opts[:type] == 'album'
     didl_metadata = "&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;00030020_t%3a%3a#{opts[:track]}%3a%3aa%3a%3a#{opts[:album]}&quot; parentID=&quot;0004006c_a%3a%3a#{opts[:album]}&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON2823_#{opts[:username]}&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;"
     case opts[:type]
     when /track/
       uri = "x-sonos-http:_t%3a%3a#{opts[:track]}%3a%3aa%3a%3a#{opts[:album]}.#{opts[:format]}?sid=11&amp;flags=32"
     when /album/
       type_id = '0004006c_a'
       uri = "x-rincon-cpcontainer:#{type_id}%3a%3a#{opts[:album]}"
     else
       return nil
     end
     add_to_queue(uri, didl_metadata, position)
   end
def add_rdio_to_queue ( opts = { } , position = 0 ) opts = { :username => nil , :album => nil , :track => nil , :type => 'track' , :format => 'mp3' } . merge ( opts ) return nil if opts [ :username ] . nil? return nil if opts [ :album ] . nil? return nil if opts [ :type ] == 'track' and opts [ :track ] . nil? opts [ :track ] = '' if opts [ :type ] == 'album' didl_metadata = "&lt;DIDL-Lite xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot; xmlns:r=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot; xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot;&gt;&lt;item id=&quot;00030020_t%3a%3a#{opts[:track]}%3a%3aa%3a%3a#{opts[:album]}&quot; parentID=&quot;0004006c_a%3a%3a#{opts[:album]}&quot; restricted=&quot;true&quot;&gt;&lt;dc:title&gt;&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;&lt;desc id=&quot;cdudn&quot; nameSpace=&quot;urn:schemas-rinconnetworks-com:metadata-1-0/&quot;&gt;SA_RINCON2823_#{opts[:username]}&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;" case opts [ :type ] when / track / uri = "x-sonos-http:_t%3a%3a#{opts[:track]}%3a%3aa%3a%3a#{opts[:album]}.#{opts[:format]}?sid=11&amp;flags=32" when / album / type_id = '0004006c_a' uri = "x-rincon-cpcontainer:#{type_id}%3a%3a#{opts[:album]}" else return nil end add_to_queue ( uri , didl_metadata , position ) end
Add an Rdio object to the queue (album or track), anything else can only
be streamed (play now).
Add an Rdio object to the queue ( album or track ) anything else can only be streamed ( play now ) .
# can be changed, but only 'mp3' is valid. # Both tracks and albums require the album key. And tracks need a track # key of course. # In order for valid DIDL we'll pass an empty :track for albums.
opts
<not_specific>
position
<not_specific>
param[Hash]
opts Various options (album/track keys, username and type)
opts Various options ( album / track keys username and type )
param[Integer]
position Optional queue insertion position. Leaving this blank inserts at the end.
position Optional queue insertion position . Leaving this blank inserts at the end .
return[Integer]
Queue position of the added track(s)
Queue position of the added track ( s )