Roon extension - http APIs


Thank you Bastian for your detailed node management lesson …
And congrats for HTTP API again !

(Danny Dulai) #42

@St0g1e – is there a reason why you didnt have player.js just speak to the broker core directly? no apps.js needed (other than to serve the html/js static files).

Additionally, you wouldnt have to make a simple but tedious wrapper around the moo ws stuff in apps.js

(Fernando Fuentes) #43

@St0g1e is it possible to add a progress bar and what song is coming next?

(Fernando Fuentes) #44

@St0g1e today I am getting:

> REQUEST 5 com.roonlabs.image:1/get_image {"image_key":null,"scale":"fit","width":300,"height":200,"format":"image/jpeg"}
<- COMPLETE 5 InvalidRequest {"message":"JSON: missing required string field: image_key"}
        socket.emit('image', { image: true, buffer: body.toString('base64') });

TypeError: Cannot read property 'toString' of undefined
    at /roon_projects/roon-extension-ws-player/apps.js:122:57
    at core.moo.send_request (/roon_projects/roon-extension-ws-player/node_modules/node-roon-api-image/lib.js:53:41)
    at Moo.handle_response (/roon_projects/roon-extension-ws-player/node_modules/node-roon-api/moo.js:167:13)
    at (/roon_projects/roon-extension-ws-player/node_modules/node-roon-api/lib.js:388:21)
    at WebSocket.onMessage (/roon_projects/roon-extension-ws-player/node_modules/ws/lib/WebSocket.js:442:14)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.onbinary (/roon_projects/roon-extension-ws-player/node_modules/ws/lib/WebSocket.js:848:10)
    at /roon_projects/roon-extension-ws-player/node_modules/ws/lib/Receiver.js:628:18
    at Receiver.applyExtensions (/roon_projects/roon-extension-ws-player/node_modules/ws/lib/Receiver.js:371:5)

No changes to the code.

(Fernando Fuentes) #45

So I been testing both interface today… The new one does not work for me.
Every time I change the zone the play and pause get stuck on the old zone even though I have changed the zones…

The old code with the two min implementation works just fine…

(Bastian) #46

Hi @Tech_Whisky_Lab,

I have fixed both the zone change and missing album image issue.

I seem to remember there is a seek function to jump within a song. Let me see if I can add the progress bar and the jump function.

As for the next song information, i don’t think that information is available through the API.


(Bastian) #47

Hi @danny,

The reason i have separate .js for the player is because i would like the apps.js to be used by other clients (i was thinking of doing a native iOS client in swift).

As for using the moo stuff, i am basing the code from the examples on your GitHub page, which is part of the node-roon-api. If there is a simpler/better way, could you point me in the right direction and i’ll update it for others to use.

Thank you very much for your help.


(Fernando Fuentes) #48

Thanks! I’ll give it a try when I get home. Thanks again!

(Fernando Fuentes) #49

@St0g1e All working! Thanks again, Super stoked on the upcoming futures :smiley:
Thanks again!

(Bastian) #50

Hi @Tech_Whisky_Lab,

I’ve updated the repository with the seek function.
You can click on the progress bar to jump to that section.

For those zones that you can control the volume, i’ve move the slider to below play/pause, next, and prev buttons.


(Fernando Fuentes) #51

Awesome! Will test soon!
Thanks again!

(Fernando Fuentes) #52

@St0g1e I ran in to a problem.

root@darkdreams:/roon_projects/roon-extension-ws-player# git pull
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 15 (delta 11), reused 14 (delta 10), pack-reused 0
Unpacking objects: 100% (15/15), done.
34406fc…eeeb3f3 master -> origin/master
Updating 34406fc…eeeb3f3
apps.js | 69 +++++++++++++++++++++++++++++++±–
package.json | 3 ±
player.html | 19 ++++±----
player.js | 139 +++++++++++++++++++++++++++++++++++++++++++++±----------------------
small.css | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++±----------------
style.css | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++±---------------------
6 files changed, 451 insertions(+), 138 deletions(-)
root@darkdreams:/roon_projects/roon-extension-ws-player# nodejs .
throw err;

Error: Cannot find module ‘node-roon-api-settings’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/roon_projects/roon-extension-ws-player/apps.js:5:24)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
root@darkdreams:/roon_projects/roon-extension-ws-player# nodejs . [/quote]

(Christopher Rieke) #53

Run npm install first.

(Fernando Fuentes) #54



(Bastian) #55

Hi @Tech_Whisky_Lab ,

Yes, as @crieke mention, you would need to re run npm install again since we have added a new dependency for the default values.

If you go to roon’s extension page, you can click on the “settings” button to enter 2 default values:

  1. HTTP Port (thanks Christopher). You can change the port if for some reason this is already been used.

  2. Default Zone. Previously the zone that is displayed when (re)connecting is whichever Zone is returned by roon. You can specify which zone you’d like to have displayed as a default here. Make sure you enter it exactly as in roon.


(Fernando Fuentes) #56

@St0g1e is it possible to identify local or tidal album playing and have it display? Like maybe the Tidal logo over Tidal albums and the roon logo for local?
Just ideas! :smiley:


(Bastian) #57

Hi Fernando,

I can’t add the tidal logo as there is no information returned on whether the track playing is sourced from Tidal or locally.

Thanks for ideas and keep them coming :slight_smile:
if it is possible i’ll try to add them.


(Bastian) #58

Hi All,

I have updated the player app with search functions.
You can get to this page by clicking on the magnifying icon next to the zone list.

You can browse to Album level and play the album for the zone.

There are several limitations that i’m still stuck on how to fix it, for example, we cannot have more than one client running the search/browse.


Roon Extension: Roon Web Controller v1.0.0 (on GitHub)
(Fernando Fuentes) #59

@St0g1e AWESOME!

(Fernando Fuentes) #60


I did a git pulll and and just incase a npm install:

and got:

root@darkdreams:/roon_projects/roon-extension-ws-player# nodejs .
Listening on port: 3002
-> REQUEST 0 com.roonlabs.registry:1/info
<- COMPLETE 0 Success {“core_id”:“4a65ce19-8183-4440-aafc-10fdfbff6db8”,“display_name”:“darkdreams”,“display_version”:“1.3 (build 223) stable”}
-> REQUEST 1 com.roonlabs.registry:1/register {“extension_id”:“st0g1e.roon-ws-browser”,“display_name”:“roon-ws-browser”,“display_version”:“0.0.1”,“publisher”:“bastian ramelan",“email”:"”,“required_services”:[“com.roonlabs.transport:1”,“com.roonlabs.image:1”,“com.roonlabs.browse:1”],“optional_services”:[],“provided_services”:[“com.roonlabs.status:1”,“com.roonlabs.settings:1”,“com.roonlabs.pairing:1”,“”],“token”:“611614d0-8b3b-4480-acf5-1c4655e735e2”}
/roon_projects/roon-extension-ws-player/apps.js:181, {“scale”: “fit”, “width”: 300, “height”: 200, “format”: “image/jpeg”}, function(cb, contentType, body) {

TypeError: Cannot read property ‘services’ of undefined
at Socket. (/roon_projects/roon-extension-ws-player/apps.js:181:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at /roon_projects/roon-extension-ws-player/node_modules/
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
root@darkdreams:/roon_projects/roon-extension-ws-player# nodejs .[/code]