[Plugin] pirate audio

then i hope that @AxLED has more ideas. I don’t

@eddie23

this is the interesting part

Dec 29 19:26:21 volumio volumio[708]: info: Executing install.sh
Dec 29 19:26:21 volumio sudo[1262]: pam_unix(sudo:auth): authentication failure; logname= uid=1000 euid=0 tty= ruser=volumio rhost=  user=volumio
Dec 29 19:26:23 volumio sudo[1262]: pam_unix(sudo:auth): conversation failed
Dec 29 19:26:23 volumio sudo[1262]: pam_unix(sudo:auth): auth could not identify password for [volumio]
Dec 29 19:26:23 volumio sudo[1262]:  volumio : 1 incorrect password attempt ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh /data/plugins/miscellanea/pirateaudio/install.sh
Dec 29 19:26:23 volumio volumio[708]: info: Install script return the error Error: Command failed: echo volumio | sudo -S sh /data/plugins/miscellanea/pirateaudio/install.sh > /tmp/installog
Dec 29 19:26:23 volumio volumio[708]: [sudo] password for volumio: Sorry, try again.
Dec 29 19:26:23 volumio volumio[708]: [sudo] password for volumio:
Dec 29 19:26:23 volumio volumio[708]: sudo: no password was provided
Dec 29 19:26:23 volumio volumio[708]: sudo: 1 incorrect password attempt
Dec 29 19:26:23 volumio volumio[708]: info: An error occurred installing the plugin. Rolling back config
  • which tool are you using to connect via ssh to the pi? (i use bitvise ssh client)
  • which user are you using?
  • did you change the default password? See also this thread
  • do you know your password?

AxLED

Oboy, missed those lines.

  • Did you change the default volumio password, if so revert back?
  • Did you enter the wrong password during install (if sudo was needed)

@AxLED , @Wheaten
Well, I have changed my password from default as a first step after connecting to volumio via ssh.
As OS doesn’t allow to revert the password (it says, that the password is very similar to previous one), I did a clean install. And the plugin installed correctly!
I didn’t have time to check functionality. I’ll do it next year. But my initial problem is solved!
Thank you very much, guys!

@AxLED - a quick question - how easy would it be to adapt your addon to limit the menu options (and also playback) to only web radio?

I’m working on creating myself a portable radio, and would like to use the Pirate Audio as the guts of it via your plugin. But it would just be using web radio, without any other sources (no locally stored media, servers or playlists) so I’d like to just have the web radio sub-menu options (and possibly even simply the “My Web Radios” list) as the available choices without having to navigate through everything else.

I’m looking through the display.py script in the plugin and I can generally follow what is going on via the socketio library, but would appreciate any inputs you can give on where to specifically look to modify things. I’m not so used to working with the API, so would appreciate any pointers that you can give.

@DarrenHill

check the lines 122-124, this is where the first menu page is put together.
Try

nav_array_name = [obj_trans['DISPLAY']['MUSICSELECTION']]
nav_array_uri = ['']
nav_array_type = ['']

AxLED

@AxLED - thanks, I’ve already done something like that (keeping the shutdown/reboot options):

nav_array_name = [obj_trans['DISPLAY']['MUSICSELECTION'], obj_trans['DISPLAY']['SHUTDOWN'], obj_trans['DISPLAY']['REBOOT']]
nav_array_uri = ['', 'shutdown', 'reboot']
nav_array_type = ['', 'emit', 'emit']

What I was more looking to do was replace the “Music selection” option directly with the “Web Radio” one that is a next level down option once you have selected it.

Is that possible, presumably by using a suitable uri and type or via some other way?

1 Like

@AxLED - I just wanted to come back to this, as I’ve now got a working version that is focussed primarily on the radio elements.

Firstly I must applaud and thank you for the clear and useful commenting and debug logging you put into your script - made things quite easy to follow and with the debugging/logging I could follow what was being called where and how I could get it to work (and that I should have been aiming at the browseLibrary rather than browseSources to get what I wanted :wink: ).

Secondly I should probably apologise for the semi-hack job I’ve made on the code, but as I said before I’m not a particularly skilled coder. I also took out the translation in the menu array as it was just for me, but it is of course trivial to put it back in should anyone else want to.

I’ve put the radio version of display.py onto Pastebin should anyone want to use it - Pirate Audio Radio.

Just connect to your device via SCP/SSH, and copy the script to /data/plugins/miscellanea/pirateaudio and replace the original display.py script with the new one (having backed it up first in case you want to revert).

Also I put together a quick screensaver (blanking) script as well for my radio, just to save batteries and screen life. Again it’s a quick and dirty hack (fixed 5 minute switch-off time in the script, but would be pretty simple to add a variable to set it via the web GUI), but it does what I wanted it to.

I’ve set it up as a separate systemd service running in parallel with the pirateaudio one, and it seems to work fine. I deliberately didn’t clean up the GPIO pins in it, as if you do then of course it will kill the pins on the main script too. Just push any of the buttons to wake the screen up again.

Again for those who want it - Pirate Audio Screensaver

3 Likes

@DarrenHill,

cool to hear my code helped you for your individual volumio setup.
One questions to the screensaver, are you running this python script in addition to display.py?
If yes, dont you get problems with your buttons, as 2 python scripts are listening on the same GPIOs?
Another tipp to save battery is not only the display background LED power it is also the cpu power your 2 python scripts produce/need.

Spoiler: I am working on a optimized pirateaudio code with new features. Unfortunatelly the volumio team needs long time to merge open plugin pull requests. I hope the volumio team finds some time if volumio 3 bug workloads reduces.

AxLED

1 Like

The two scripts do seem to be working fine so far together, but I admit I had wondered that myself (and as noted, they do interact if you clean up GPIO in one script the buttons stop working for both). The screensaver doesn’t really do anything with the buttons other than detect them, so as I’m not trying to control anything with them I guess there’s little/no conflict.

This was just playing around to see if I could get things to work. My longer term plan was to strip out the unused bits from the code (prev/next, seek etc) and also to try to merge the two scripts together.

But if you’re working on an optimisation then I’ll pause it for now and look at it again once you’ve done your work and the addon is published into the store.

At the moment the battery life seems like it’s fine (it’s running from a 1000mAH Waveshare UPS hat) so it was more to stop anything happening to the screen for burn-in or something like that. But all good experience on Python coding and SocketIO anyway :smiley:

Hi, I went through the appropriate steps for install, but I am now getting stuck in this feedback loop:

info: CoreCommandRouter::volumioGetState
info: CoreCommandRouter::volumioGetQueue
info: CoreStateMachine::getQueue
info: CorePlayQueue::getQueue
register 5
success
register 6
success
register 16
success
register 20
success
Traceback (most recent call last):
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 590, in
main()
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 585, in main
socketIO.wait()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 251, in wait
self._process_packets()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 278, in _process_packets
self._process_packet(engineIO_packet)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 491, in _process_packet
delegate(parse_socketIO_packet_data(socketIO_packet_data), namespace)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 513, in _on_event
namespace._find_packet_callback(event)(*args)
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 339, in on_push_state
position = args[0][‘position’] # v.0.0.4
KeyError: ‘position’
pirateaudio.service: Main process exited, code=exited, status=1/FAILURE
pirateaudio.service: Failed with result ‘exit-code’.
pirateaudio.service: Service RestartSec=100ms expired, scheduling restart.
pirateaudio.service: Scheduled restart job, restart counter is at 14.
Stopped Service for using pirate audio display in volumio.
Started Service for using pirate audio display in volumio.

info: CoreCommandRouter::volumioGetState
info: CoreCommandRouter::volumioGetQueue
info: CoreStateMachine::getQueue
info: CorePlayQueue::getQueue
register 5
success
register 6
success
register 16
success
register 20
success
Traceback (most recent call last):
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 590, in
main()
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 585, in main
socketIO.wait()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 251, in wait
self._process_packets()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 278, in _process_packets
self._process_packet(engineIO_packet)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 491, in _process_packet
delegate(parse_socketIO_packet_data(socketIO_packet_data), namespace)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 513, in _on_event
namespace._find_packet_callback(event)(*args)
File “/data/plugins/miscellanea/pirateaudio/display.py”, line 339, in on_push_state
position = args[0][‘position’] # v.0.0.4
KeyError: ‘position’
pirateaudio.service: Main process exited, code=exited, status=1/FAILURE
pirateaudio.service: Failed with result ‘exit-code’.
pirateaudio.service: Service RestartSec=100ms expired, scheduling restart.
pirateaudio.service: Scheduled restart job, restart counter is at 15.
Stopped Service for using pirate audio display in volumio.
Started Service for using pirate audio display in volumio.

This is after installing from your recently updated repository as well

@SirNut

it seems that the expected Websocket player state value “position” is missing. From which source are you trying to play music?

AxLED

I’m using the Spotify connect2 plugin from the plugins section, and then I manually install the pirate audio plugin

1 Like

@SirNut

can you please try, if the pirate audio plugin is working with local stored music or radio?
@ashthespy
is it possible you can post the player state result of volumio.local/dev if one of “volatile” service is used, as i dont use them or dont have the possibility to test it. So i can put this topic on my “list to improve”.

AxLED

I can confirm this behaviour - pirate audio crashes when using Spotify Connect2 plugin. Traceback points to:

Traceback (most recent call last):
File “display.py”, line 623, in
main()
File “display.py”, line 618, in main
socketIO.wait()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 251, in wait
self._process_packets()
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 278, in _process_packets
self._process_packet(engineIO_packet)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 491, in _process_packet
delegate(parse_socketIO_packet_data(socketIO_packet_data), namespace)
File “/usr/local/lib/python3.7/dist-packages/socketIO_client/init.py”, line 513, in _on_event
namespace._find_packet_callback(event)(*args)
File “display.py”, line 347, in on_push_state
position = args[0][‘position’] # v.0.0.4
KeyError: ‘position’

Running volumio status at this point gives:

{
“status”: “play”,
“title”: “”,
“artist”: “”,
“album”: “”,
“albumart”: “/albumart”,
“uri”: “”,
“trackType”: “spotify”,
“seek”: 30000,
“duration”: 0,
“samplerate”: “44.1 KHz”,
“bitdepth”: “16 bit”,
“channels”: 2,
“consume”: false,
“volume”: 33,
“dbVolume”: null,
“mute”: false,
“stream”: false,
“updatedb”: false,
“volatile”: true,
“service”: “volspotconnect2”
}

Spotify Connect2 sets up the pi as a destination for playback of the music whilst controlling it from a networked phone / PC etc. I’ve also tried using the Spotify plugin (running Spotify on the pi itself as a music source), which displays cover art on pirate audio correctly, and always returns a ‘position’ of 0, and a sensible value for ‘duration’, e.g.

{
“status”: “play”,
“position”: 0,
“title”: “Famous Last Words”,
“artist”: “James Blake”,
“album”: “Friends That Break Your Heart”,
“albumart”: “https://i.scdn.co/image/ab67616d0000b27371863d7666c4cffc68000806”,
“uri”: “spotify:track:6ZvUYfwlxahmoFQuEkTlDL”,
“trackType”: “spotify”,
“seek”: 110524,
“duration”: 256,
“samplerate”: “320Kbps”,
“bitdepth”: “16 bit”,
“random”: null,
“repeat”: null,
“repeatSingle”: false,
“consume”: false,
“volume”: 100,
“dbVolume”: null,
“disableVolumeControl”: true,
“mute”: false,
“stream”: “spotify”,
“volatile”: false,
“service”: “spop”
}

I guess the values available in the various fields will depend on the plugin. One could argue that the plugin developer should be populating these fields with a 0 or something sensible, but I guess that non-availability of these data should be handled.

Strange that the connect plugin shows duration as 0. It should be updated normally

As for setting position as 0, that could lead to other funky issues, messing with the track queue. As mentioned before, all “volatile” - volumio’s jargon for sources not controlled from within the webUI would not have this queue position - simply cause playback for these services can’t be started from the traditional queue.

@arckuk @SirNut

maybe someone can try this quick fix.
Edit display.py as follows:

  • replace Line 339
    position = args[0]['position'] # v.0.0.4
  • with
if 'position' in args[0]:
 position = args[0]['position']  # v.0.0.4
  • Save display.py and restart pirate audio plugin via volumio GUI.

No it should work with music services, that dont push ‘position’ via websocket.
Little restriction: with this quick fix: Skip next/prev on pirate audio menu will not work (as this function needs a value for position) when music service dont push ‘position’.

Would be nice if someone could test this, since I unfortunately can not test it.

AxLED

2 Likes

disclaimer: I haven’t looked at your code, but I hope you aren’t managing queue state yourself? You can use the Volumio API’s next and prev functions directly?

@AxLED I’ve edited the line as you suggest, and everything now works, with correct artist, track and albumart information. Since I replied to your earlier post, I rebooted my pi, and volumio status now gives more sensible values for title, artist albumart etc when using Spotify Connect2 (but position is still undefined, so this fix is necessary):

{
“status”: “play”,
“title”: “Ceremony”,
“artist”: “New Order”,
“album”: “Substance”,
“albumart”: “https://i.scdn.co/image/ab67616d0000b273847620cdf72cd76743159265”,
“uri”: “spotify:track:5CRPGdCSOfstyTVK9Ja5EQ”,
“trackType”: “spotify”,
“seek”: 16000,
“duration”: 264,
“samplerate”: “44.1 KHz”,
“bitdepth”: “16 bit”,
“channels”: 2,
“consume”: false,
“volume”: 100,
“dbVolume”: null,
“mute”: false,
“disableVolumeControl”: true,
“stream”: false,
“updatedb”: false,
“volatile”: true,
“service”: “volspotconnect2”
}