24.11.2015, 12:23
(23.11.2015, 12:49)admin Wrote: We don't have any Sonos devices so what we can help with is limited.
You can use Node.js library with debug enabled to monitor which kind of requests are being sent and then implement the same thing in LM.
Some hints for your case:
- To find your playlist id (SQ:1 or similar), you need to get a list of all playlists and find it there
- Use RemoveAllTracksFromQueue to empty current queue
- Use SetPlayMode to set repeat / shuffle
- You don't have to add tracks one by one, you can load the whole playlist (stored queue) in one call
Yes.. it works.
I attached a little bit changed upnpavcmd function.
And two new functions:
Code:
-- find all playlist
function getPlaylists(ip, port)
cBrowse = '<ObjectID>SQ:</ObjectID>' ..
'<BrowseFlag>BrowseDirectChildren</BrowseFlag>' ..
'<Filter>*</Filter>' ..
'<StartingIndex>0</StartingIndex>' ..
'<RequestedCount>25</RequestedCount>' ..
'<SortCriteria>*</SortCriteria>'
res,err = upnpavcmd(ip, port, 'Browse', cBrowse)
return res,err
end
-- add saved queue (playlist) to queue
function qPlaylist(pId)
uriprm = '<EnqueuedURI>file:///jffs/settings/savedqueues.rsq#'..pId..'</EnqueuedURI>' ..
'<EnqueuedURIMetaData></EnqueuedURIMetaData>' ..
'<DesiredFirstTrackNumberEnqueued>0</DesiredFirstTrackNumberEnqueued>' ..
'<EnqueueAsNext>1</EnqueueAsNext>'
return uriprm
end
-- find all playlist (run once and note playlist id)
res,err = getPlaylists(ip, 1400)
log(res)
And then you can use:
Code:
-- clear current queue
upnpavcmd(ip, 1400, 'RemoveAllTracksFromQueue')
-- add playlist to queue
upnpavcmd(ip, 1400, 'AddURIToQueue', qPlaylist(2)) -- add the playlist id here
-- play
uri_queue = "x-rincon-queue:RINCON_B8E937A06A3E01400#0" -- add the right URI for the queue
upnpavcmd(ip, 1400, 'SetAVTransportURI', '<CurrentURI>'..uri_queue..'</CurrentURI><CurrentURIMetaData/>')
upnpavcmd(ip, 1400, 'Play', '<Speed>1</Speed>')