spotblock icon indicating copy to clipboard operation
spotblock copied to clipboard

Flush spotify streams before unmuting

Open mahkoh opened this issue 8 years ago • 10 comments

When the streams are unmuted they often still contain a bit of ad because they are buffered.

mahkoh avatar Jun 20 '16 11:06 mahkoh

Yes I can confirm this behaviour, it is just below a second. Thanks for the good work!

ghost avatar Sep 19 '16 19:09 ghost

I don't think this can be fixed. The real solution is for spotify to become latency aware. You can see the same effects in the UI when it already shows the next song even though the old one is still playing.

mahkoh avatar Sep 21 '16 09:09 mahkoh

Why not just adding half a sec of an offset value?

ghost avatar Sep 21 '16 10:09 ghost

Unfortunately the latency is not consistent.

mahkoh avatar Sep 22 '16 17:09 mahkoh

What about adding an unmute delay of about 5 seconds and prior to unmuting encourage spotify to jump to the beginning of the current song?

gCurse avatar Apr 20 '17 20:04 gCurse

Ideally we would seek to 0 once the ad ends. This would flush the buffer. However, spotify does not support seeking via MPRIS.

mahkoh avatar Apr 29 '17 14:04 mahkoh

But spotify supports "Previous" which seeks to 0 if the song is playing for about 3 (or more) seconds. I now use this script (see lines 56-57) and it works ~~~seamlessly~~~ fine for me.

gCurse avatar Apr 29 '17 14:04 gCurse

I'd hardly call this working seamlessly:

            if advert:
                advert = False
                time.sleep(6.0)
                player.Previous()

            pulsesink_mute(0)

But since the interval is only 3 seconds I might think about implementing this properly.

mahkoh avatar Apr 29 '17 14:04 mahkoh

If it helps, here's how to do prev for spotify:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Prev

ghost avatar Sep 11 '20 09:09 ghost

Presumably, in this case, at the point of the notification, the audio buffer power level is at non 0 (playing the tail end of the ad). The audio buffer level presumably then goes to 0 output amplitude for at least a sample at the end of the advert, no? Could detecting that 0 volume sample be used to trigger unmuting the audio?

mxmilkiib avatar Jul 14 '23 02:07 mxmilkiib