[collected] "airplay active" status indicator in webUI

I’ve just updated to 1.4 on my UDOO quad. Great improvements!

I’ve spent several hours trying to implement an Airplay status indicator on the webUI, but can’t seem to get it to work.

I’ve noticed that in version 1.4 shairport is managed through player_wrk.php, but i’m stuck trying to figure out how to let client devices know that airplay streaming is active.

I’m not asking for a complete solution. I’m comfortable managing PHP and web technologies and languages in general. But if anyone could point me in the right direction it would be really appreciated. :slight_smile:

regards.

So I’m doing something similar. There is a fork in the shairport code that actually contains an improvement that will write metadata out to a file. I’ve been messing with this a little bit. If you can get PHP to periodically read a file for status, then we can implement this easily.

Want to work on it together? I’ll be happy to share my shairport code mods to be able to output metadata and status to a file.

Cheers,
S

Hi SammyJ! It would be awesome!
Did you update shairport? Or the current version included in Volumio 1.4 is ok?

Maybe this is a start. I’ll try it later:
github.com/abrasive/shairport/issues/281

So I forked wnielson’s changes. It should be with the relatively latest version of shairport. I had to build it on the RPi, so I don’t know if it’ll work on other devices.

Let me get it to a place where I can share. Are you any good with inter-process signals or messaging? Right now, it’s writing state and metadata to a file, but it would be great to have it message a service that would inform the UI of the status change. The PHP pages are hosted through nginx, don’t know of any way to message a PHP page. The best I’ve been able to do is have the metadata file located in an nginx hosted directory, then use jquery to refresh a metadata page ever X seconds and read status.

For that I solved it through a constant jquery AJAX call and a text file that is filled with whatever information you need updated in the UI. Something like:

function yourFunction(){
$.ajax({
type: 'GET',
url: '_txt_file_with_contents.php', 
async: true,
cache: false,
success: function(response){
                 UI update here;
                 yourFunction(); //this causes the function to run constantly
               },
                error: function(){
                  yourFunction(); //function gets called regardless of momentary connection errors.
               }
});
}

You can place this function in js/player_lib.js, and call the function somewhere in js/scripts-playback.js (it just needs to be called once).

This is the only (hackish) way I’ve found to update the UI in realtime, although I know there must be an easier and more memory-efficient solution.

UPDATE: You can use the raw txt file (no php needed). I’ve changed this post accordingly. :slight_smile:

Yup, I’ve got something similar. I’m travelling at the moment and don’t have access to my source (it’s on the rPI unfortunately, which is at home). I’ll try to upload my code to github this weekend.

Cool! Have a nice trip.

Looking forward to know how you solved the metadata thing. It would be a great improvement to volumio.

Yep, eager to see what you did! If you want you can also send a pull request, if it works reasonably good it will go to master!

Ok, I managed to implement the “airplay status” indicator using the technique described above.

Shairport “start” an “stop” functions included in the shairport functionality (shairport -h will give all the available options) echo “1” and “0” respectvely to a text file which gets polled via jquery AJAX every 500 ms. I even made a LED indicator using UDOO’s GPIOs.

I would like to share it soon, but i’m still waiting for sammyj and see how all the metadata stuff turned out.

Another feature I would want to implement is a “UPNP status” indicator but it seems that UPMPDCLI doesn’t have those handy “start” and “stop” functions included in shairport. Any ideas would be highly appreciated.

After some research I found out that upmpdcli can get its mpd tcp port assigned in the conf file. Maybe I can check for traffic on that particular port and when traffic is greater trigger the “upnp active” indicator. I’ll try it soon.

Here’s some code with metadata output in shairport: github.com/dangerjain/shairport

You’ll have to build shairport locally (and likely have to install some gcc libraries, since they are removed in Volumio).

in your /etc/init.d/shairport file, you need to include a -C parameter with a filepath to export the metadata content to. I’m going to upload some more examples in a minute to the git repository

Can it output via tcp or udp? This way we can see the now playing infos on WebUI and players using MPD clients protocol