[GH-ISSUE #527] Duplicate event playing with "onevent" #337

Closed
opened 2026-02-27 19:30:05 +03:00 by kerem · 6 comments
Owner

Originally created by @all3kcis on GitHub (Sep 29, 2020).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/527

I added "onenvent" param and when a test with something like :

#!/bin/sh
echo Spotify event: --------------------------------------------- >> /install/test.log
echo PLAYER_EVENT: $PLAYER_EVENT >> /install/test.log
echo TRACK_ID:     $TRACK_ID >> /install/test.log
echo OLD_TRACK_ID: $OLD_TRACK_ID >> /install/test.log

I get :

Spotify event: ---------------------------------------------
PLAYER_EVENT: paused
TRACK_ID: 7FEltWF1lj6brKHafmAEt0
OLD_TRACK_ID:
Spotify event: ---------------------------------------------
PLAYER_EVENT: playing
TRACK_ID: 7FEltWF1lj6brKHafmAEt0
OLD_TRACK_ID:
Spotify event: ---------------------------------------------
PLAYER_EVENT: playing
TRACK_ID: 7FEltWF1lj6brKHafmAEt0
OLD_TRACK_ID:

And if I change song :

PLAYER_EVENT: change
TRACK_ID: 4SNtyKNyYJ8ERT7YLlnFBr
OLD_TRACK_ID: 1mweJExKILP5pxrPpIQwHQ
Spotify event: ---------------------------------------------
PLAYER_EVENT: playing
TRACK_ID: 4SNtyKNyYJ8ERT7YLlnFBr
OLD_TRACK_ID:

Why "playing" event is raised in the same time ?
I think I used V 0.1.3, but how can I check that ?

I would like to execute an action on "playing".
to turn on the amp with a CEC control
But if the event is raised twice, this can be a problem.

Originally created by @all3kcis on GitHub (Sep 29, 2020). Original GitHub issue: https://github.com/librespot-org/librespot/issues/527 I added "onenvent" param and when a test with something like : ```sh #!/bin/sh echo Spotify event: --------------------------------------------- >> /install/test.log echo PLAYER_EVENT: $PLAYER_EVENT >> /install/test.log echo TRACK_ID: $TRACK_ID >> /install/test.log echo OLD_TRACK_ID: $OLD_TRACK_ID >> /install/test.log ``` I get : ```sh Spotify event: --------------------------------------------- PLAYER_EVENT: paused TRACK_ID: 7FEltWF1lj6brKHafmAEt0 OLD_TRACK_ID: Spotify event: --------------------------------------------- PLAYER_EVENT: playing TRACK_ID: 7FEltWF1lj6brKHafmAEt0 OLD_TRACK_ID: Spotify event: --------------------------------------------- PLAYER_EVENT: playing TRACK_ID: 7FEltWF1lj6brKHafmAEt0 OLD_TRACK_ID: ``` And if I change song : ``` PLAYER_EVENT: change TRACK_ID: 4SNtyKNyYJ8ERT7YLlnFBr OLD_TRACK_ID: 1mweJExKILP5pxrPpIQwHQ Spotify event: --------------------------------------------- PLAYER_EVENT: playing TRACK_ID: 4SNtyKNyYJ8ERT7YLlnFBr OLD_TRACK_ID: ``` Why "playing" event is raised in the same time ? I think I used V 0.1.3, but how can I check that ? I would like to execute an action on "playing". to turn on the amp with a CEC control But if the event is raised twice, this can be a problem.
kerem closed this issue 2026-02-27 19:30:06 +03:00
Author
Owner

@JasonLG1979 commented on GitHub (Oct 6, 2020):

It's not a perfect solution but why not just throttle the playing event if all your getting is double events?

<!-- gh-comment-id:704068051 --> @JasonLG1979 commented on GitHub (Oct 6, 2020): It's not a perfect solution but why not just throttle the playing event if all your getting is double events?
Author
Owner

@all3kcis commented on GitHub (Oct 8, 2020):

In the end, I didn't need the "playing" event for what I wanted to do, just start/stop.

But the question remains open about the duplication of the "playing" event.
Maybe it should sometimes be "on_playing" versus "start_playing".

<!-- gh-comment-id:705480306 --> @all3kcis commented on GitHub (Oct 8, 2020): In the end, I didn't need the "playing" event for what I wanted to do, just start/stop. But the question remains open about the duplication of the "playing" event. Maybe it should sometimes be "on_playing" versus "start_playing".
Author
Owner

@JasonLG1979 commented on GitHub (Oct 8, 2020):

But the question remains open about the duplication of the "playing" event.
Maybe it should sometimes be "on_playing" versus "start_playing".

I don't know, maybe it represents the latency between when it received the instruction to play vs when playback actually began?

<!-- gh-comment-id:705557976 --> @JasonLG1979 commented on GitHub (Oct 8, 2020): > But the question remains open about the duplication of the "playing" event. > Maybe it should sometimes be "on_playing" versus "start_playing". I don't know, maybe it represents the latency between when it received the instruction to play vs when playback actually began?
Author
Owner

@kingosticks commented on GitHub (Oct 8, 2020):

Playing sounds like the wrong event for what you want:
github.com/librespot-org/librespot@a2f832dff1/playback/src/player.rs (L104-L116)

Started sounds more suited to your use-case:
github.com/librespot-org/librespot@a2f832dff1/playback/src/player.rs (L85-L91)

Do you see that initial Started event?

<!-- gh-comment-id:705603372 --> @kingosticks commented on GitHub (Oct 8, 2020): `Playing` sounds like the wrong event for what you want: https://github.com/librespot-org/librespot/blob/a2f832dff171914935f7e1a98a5da3d7c8a0b789/playback/src/player.rs#L104-L116 `Started` sounds more suited to your use-case: https://github.com/librespot-org/librespot/blob/a2f832dff171914935f7e1a98a5da3d7c8a0b789/playback/src/player.rs#L85-L91 Do you see that initial `Started` event?
Author
Owner

@all3kcis commented on GitHub (Oct 9, 2020):

As I said, in my case yes, I used only the "started" event.

Thanks for the quotes, I conclude that even if it's astonishing it's the expected behaviour.

<!-- gh-comment-id:706127996 --> @all3kcis commented on GitHub (Oct 9, 2020): As I said, in my case yes, I used only the "started" event. Thanks for the quotes, I conclude that even if it's astonishing it's the expected behaviour.
Author
Owner

@kingosticks commented on GitHub (Oct 9, 2020):

We can close this then.

<!-- gh-comment-id:706129514 --> @kingosticks commented on GitHub (Oct 9, 2020): We can close this then.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#337
No description provided.