mahkoh / spotblock

A minimal spotify ad blocker
GNU General Public License v3.0
35 stars 1 forks source link

Flush spotify streams before unmuting #1

Open mahkoh opened 8 years ago

mahkoh commented 8 years ago

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

ghost commented 8 years ago

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

mahkoh commented 8 years ago

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.

ghost commented 8 years ago

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

mahkoh commented 8 years ago

Unfortunately the latency is not consistent.

gCurse commented 7 years ago

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?

mahkoh commented 7 years ago

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

gCurse commented 7 years ago

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.

mahkoh commented 7 years ago

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.

ghost commented 4 years ago

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
mxmilkiib commented 1 year ago

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?