Need help with Websocket API

Volumio Version: 2.873 (also seen with Buster Beta 3.066)
Hardware: RPi 3B
DAC: Hifiberry AMP2

I’m using a python script running on another device using the socketio library to control Volumio, it’s working well but but I’m having trouble getting a track to continue from the same position after pause.

If I use the Web UI all works as expected - track is playing, click pause, the song stops, press play, the song starts again where it left off.

But from the Websocket API I can’t replicate this behaviour.

Example: Track is playing:
emit(‘pause’, {} )
then emit(‘play’, {‘value’:0} )

Track starts from the beginning not where it stopped

I tried using ‘seek’, this works if the track is playing for example with the track playing:
emit(‘seek’, 60)
Status from pushStatus, ‘seek’ changes to 60000
Track jumps to the 60 second mark and continues

But if the track is paused:
emit(‘seek’, 60)
Status from pushStatus, ‘seek’ changes to 60000
then emit(‘play’, {‘value’:0} )
Track starts at the beginning again

Any help would be appreciated, have to say the documentation for the API is not the easiest to follow

Thanks

Just a note, I was able to find a workaround, by doing this:
emit(‘pause’, {} )
when pushStatus updates, save current value of ‘seek’

then emit(‘play’, {‘value’:0} )
wait for pushStatus to update
emit(‘seek’, value) where value = (previously saved value of ‘seek’) / 1000

This seems more complicated than it needs to be, feels like the API needs a ‘continue’ command

1 Like

Just emit play without value, since it does not need any parameters, my best guess is that when you emit value=0 it starts playback of first song in queue and from beginning obviously.

Thanks for the suggestion - you were correct.
I’ve just tested again and the following all work, restart paused track at last position
emit(‘play’, )
emit(‘play’, ‘’)
emit(‘play’, {} )
emit(‘play’, 0 )

But, as you suspect emit(‘play’, {‘value’: 0} ) restarts at the beginning

Thanks again

With REST API there is a toggle command, which toggles between play and pause:
==> volumio.local/api/v1/commands/?cmd=toggle

use ip instead of volumio.local works better :slight_smile:

Heads up, the toggle command is a bit moody when it comes to “volatile” services such as Spotify/Tidal connect, airplay, Bluetooth etc.