Roon extension - http APIs

Hi @Jean-Arnaud_Courcier,

It is one of the option. I know there are others made by fellow roonies that are still being actively developed. You can look the ones by @Mike_Plugge.

I have 3 repositories on GitHub. If you want to look at examples, the web socket repository is the one you should be looking at (https://github.com/st0g1e/roon-extension-ws-player)

Please let me know if you have any other questions

Thank you so much for your fast answer. I will definitely a socket.io implementation is great. It is the same than for volumio. I understand you are in Singapore like me. Timezone is easier.
I will keep you posted of my progress.
I would try to do something like this:
https://youtu.be/ybQrpgSK1yM
I am a roon beginner so I hope it makes sense.

Awesome. You should be able to do what youā€™ve done apart from connecting to Spotify.

If you want to connect to third party player, you can try the other repository (https://github.com/st0g1e/roon-extension-thirdparty-player) where you can play it through Audirvana. I created it when I was trying to see the difference in sound between the two.

Where are you at in Singapore? maybe we can meetup sometimes. I know of another Roon regular @wizardofoz who have helped me from Roon in general to networking.

1 Like

Always happy to meet up with local roon users here in the small red-dot and there are quite a few I knowā€¦from different places, including French, Belgian, English, Aussie, and locals too of course.

Well that would be awesome, I feel we have a few common passions and I need to get up to speed on Roon, I guess it is a terrific software. Today, I use volumio and snapcast for the multiroom, all well integrated into Neeo. But a lot of neeo users are strong fan of Roon so I need to widen my horizons :-).
And by the way I feel half French half Singaporean, French origins but in Singapore since 10 years.

Iā€™ve been here 30 yearsā€¦half my life, coffee, diy and HIFI amount to most of my other hobbies and Formula 1. Maybe we can start a roon WhatsApp Singapore group.

Iā€™m not 100% sure of exactly how this extension works (nor how to install it without extension manager on a QNAP), but I wanted to ask if it might be usable to run an http command to update an icecast metadata? I use icecasst to play to a couple of radios in my house that are not Roon ready, and it would be greaty to be able to update metadata to show a now playing text. I have a simple url that should work with curl or whatever - can this extension run it itself on track change? Many thanks.

Are you streaming into Roon via icecast as a radio stream or out of Roon via icecast to send roon audio to a streaming radio endpoint?

If out of Roon:
I dont know this extension, but if you are trying to get now playing metadata out of Roon, then you would need to subscribe to zone change events via the Roon API. I doubt that a command only solution such as this would be have a websocket back channel mode for picking up events. This means writing a new extension from scratch (not hard if you know basic javascript and node programming).

If Into Roon - I guess shoutcast for metadata insertion?

1 Like

hi @klerm,

If Iā€™m understanding your question correctly, youā€™d like to show the information on whatā€™s playing in Roon to icecast and that you have an http url command to update the icecast with.

If that is the case, you can use the websocket repository at https://github.com/st0g1e/roon-extension-ws-player

I donā€™t use QNAP so I donā€™t know about its extension manager. You can install it using command line. The step by step is at the bottom of that page.

Once you have it running, you can take a look at player.js starting at line 22

socket.on(ā€˜zonesā€™, function(msg){
if ( inRangeSlider == false ) {
zones = msg;
updateZone();
}
});

This gets call everytime there is a change in the zone metadata (including track seek information which changes every second).

You should call your url to update the icecast here.

Hope it helps.

1 Like

Thank you very much for the very speedy and informative reply - I will try thatā€¦!
Is there a way to trigger it less often, ie not every second but just on track change?

Thanks again - Iā€™ve got reasonably far in that I have the extension sitting happily in a docker container, Roon likes it, I can access it online; and Iā€™m busily trying to edit player.js at your suggestion.
However I wanted to install axios to do the HTTP request, which seems to break the extension. I can reinstall it, but then it breaks axios. Is this conflict resolvable? My Javascript is pretty weak, which is why I wanted to stick to axios to solve this.

Glad you have that running.

The notification frequency can be more than 1 per second if for example you have more than one zone running, every change on any of the zone will trigger the notification.

We canā€™t control the update frequency. But if you want to, you can limit it to only notify you on a track change on apps.js.

At line 64 where it says

io.emit(ā€œzonesā€, zones)

Before calling this, you can check whether the track has changed or not.
But be careful as it may break other clients that uses it.

As for axios, I did a quick google and see that it seems that it uses node.js as well. Could it be that they are using the same port?
You can try changing the port by going to apps.js and on line 74 change the webport value. And restarting the extension.

Hope this helps.

Hello, ii Ʈs posibile to create a small app to show artist and track on Lametric Time?

Iā€™m not familiar with lametric time, but quick google shows that they have API services. So it should be possible.

Here is the link I found:

Hope it helps.

Just want to say a quick thanks for this! Iā€™ve long wanted an easy way to get a true sharing link from Roon. After spending an hour or so figuring out how this extension works, I was able to make a few simple changes to the browser and player files to send the album or song to Songwhip, which produces a multi-platform streaming/purchasing link for it that I can then share. Iā€™m looking forward to tinkering more. Thanks, @St0g1e !

1 Like

Hi @AlanTS,

Awesome.
Are you sending the song information to the websiteā€™s search page?
I looked at the api and they only have one where we have the url to the song already.

Let me know if you need help with the extension.

Could you please share your work @AlanTS as I have too been looking for a way to get information OUT of Roon since their own ā€œshareā€ function is so limited.

Your work might save me from reinventing the wheel or worse, end up with a square wheel. Thanks i.a.!

Happy to share! In htmls/player.js. Iā€™ve commented out the original lines, and replaced them with a line that adds a ā€œshareā€ link out to songwhip.

<!--  html += "Artist: " + zone.now_playing.three_line.line2 + "<br>\n"; -->
  html += "Artist: " + zone.now_playing.three_line.line2 + " - <a href=\"" + 
  "https://songwhip.com/create?q=" + encodeURIComponent(zone.now_playing.three_line.line2) + 
  "\">share</a>" + "<br>\n";
<!--  html += "Album: " + zone.now_playing.three_line.line3 + "<br>\n"; -->
  html += "Album: " + zone.now_playing.three_line.line3 + " - <a href=\"" + "https://songwhip.com/create?q=" + encodeURIComponent(zone.now_playing.three_line.line3) + "\">share</a>" + 
 "<br>\n";
<!--  html += "Title: " + zone.now_playing.three_line.line1 + "<br>\n"; -->
  html += "Title: " + zone.now_playing.three_line.line1 + " - <a href=\"" + "https://songwhip.com/create?q=" + encodeURIComponent(zone.now_playing.three_line.line1) + "\">share</a>" +  "<br>\n";

Thereā€™s a similar change in browser.js:

for ( var i in data['list'] ) {
      html += "<div class=\"gallery\">\n";
      html += "<a href=\'javascript:void(0);\' onclick=\"showList(\'" + data.list[i].item_key + "\', \'" + zone_id + "\', 1, 5);\">";

      if ( data.list[i].image_key == null ) {
         html += "<img src=\'images/roonIcon.png\'/>\n";
      } else {
         html += "<img src=\'" + topUrl + "/roonAPI/getIcon?image_key=" + data.list[i].image_key + "\'/>\n";
      }

<!-- revised the block below to add songwhip link. It appears as an asterisk before the artist/track/album -->
      html += "</a>\n";
      html += "<div class=\"desc\">" + " - <a href=\"" + "https://songwhip.com/create?q=" + encodeURIComponent(data.list[i].title) + "\">*</a>" + data.list[i].title  + "</div>\n";
      html += "</div>\n";
    }

Yep, Iā€™m not using the API at all, just sending an html-encoded request to the search URL. Itā€™s pretty brute-force and doesnā€™t work for every use case, but itā€™s solid enough for what I want to do most of the time.

Hi @St0g1e,

thanks for this great extension it helped me a lot to control my Sonos devices via Apple Shortcuts. To fulfill my needs I just need a http request to group/ungroup zones and one for transport the music from one zone to another. Iā€™m not a programmer so I donā€™t know anything how to code something (Iā€™m happy that I can handle the http requests correct :slight_smile: ).
Is there a way to add these commands to the http API? I know that these commands can be used because the home-assistant roon extension can do them. But for me it would be nicer to have a http request instead of using this home automation software which is too much for my needs.

This would help me to handle my Sonos ungrouping problems (if I use these commands in http extension, the Soro app for Sonos (iOS shortcuts for Sonos), and the Apple Shortcuts appā€¦ I should have bought Bluesoundā€¦ :slight_smile: ) and I (and everyone else) would be able to create some Multiroom presets.

It should be possible.
Iā€™ll look at it this weekend and update you.

Thanks,
Bastian