[GH-ISSUE #81] "byte == -1" no longer works for detecting end of songs #5

Closed
opened 2026-02-27 08:11:24 +03:00 by kerem · 8 comments
Owner

Originally created by @ghost on GitHub (Oct 17, 2021).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/81

With the current version of librespot-python it no longer returns "-1" when the song ends, the best I could figure out was waiting until the byte returned is empty/null but it is by no means perfect so I was wondering if you could look into this issue please.

Originally created by @ghost on GitHub (Oct 17, 2021). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/81 With the current version of librespot-python it no longer returns "-1" when the song ends, the best I could figure out was waiting until the byte returned is empty/null but it is by no means perfect so I was wondering if you could look into this issue please.
kerem 2026-02-27 08:11:24 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@kokarare1212 commented on GitHub (Oct 17, 2021):

Thank you for your inquiry.
The method stream.input_stream.stream().read() has been changed to return all music streams if no argument is specified.
Therefore, no loop is needed.
I apologize for the inconvenience.

<!-- gh-comment-id:945202031 --> @kokarare1212 commented on GitHub (Oct 17, 2021): Thank you for your inquiry. The method `stream.input_stream.stream().read()` has been changed to return all music streams if no argument is specified. Therefore, no loop is needed. I apologize for the inconvenience.
Author
Owner

@ghost commented on GitHub (Oct 17, 2021):

Thanks for the quick reply, with the new method how can I detect the end of the song then?

<!-- gh-comment-id:945211031 --> @ghost commented on GitHub (Oct 17, 2021): Thanks for the quick reply, with the new method how can I detect the end of the song then?
Author
Owner

@kokarare1212 commented on GitHub (Oct 17, 2021):

If you write the following, the variable "data" will be filled with music data

data = stream.input_stream.stream().read()
<!-- gh-comment-id:945218642 --> @kokarare1212 commented on GitHub (Oct 17, 2021): If you write the following, the variable "data" will be filled with music data ``` data = stream.input_stream.stream().read() ```
Author
Owner

@ghost commented on GitHub (Oct 18, 2021):

Yeah but how do I know when the song has finished playing?

<!-- gh-comment-id:945268247 --> @ghost commented on GitHub (Oct 18, 2021): Yeah but how do I know when the song has finished playing?
Author
Owner

@kokarare1212 commented on GitHub (Oct 18, 2021):

The above code will pass the data up to the end of the song.
The data will be thread-blocked while it is being retrieved internally, so when the function finishes executing, the data will have been stored until the end.

<!-- gh-comment-id:945276529 --> @kokarare1212 commented on GitHub (Oct 18, 2021): The above code will pass the data up to the end of the song. The data will be thread-blocked while it is being retrieved internally, so when the function finishes executing, the data will have been stored until the end.
Author
Owner

@ghost commented on GitHub (Oct 18, 2021):

I appreaciate the explanation but i dont understanr it completely. Is there a way to make it detect the end of the track like the old way does?

<!-- gh-comment-id:945310497 --> @ghost commented on GitHub (Oct 18, 2021): I appreaciate the explanation but i dont understanr it completely. Is there a way to make it detect the end of the track like the old way does?
Author
Owner

@kokarare1212 commented on GitHub (Oct 18, 2021):

The following older branches are not actively maintained, but can be used if needed.
https://github.com/kokarare1212/librespot-python/tree/main

<!-- gh-comment-id:945319735 --> @kokarare1212 commented on GitHub (Oct 18, 2021): The following older branches are not actively maintained, but can be used if needed. https://github.com/kokarare1212/librespot-python/tree/main
Author
Owner

@ghost commented on GitHub (Oct 18, 2021):

Many thanks!

<!-- gh-comment-id:945332606 --> @ghost commented on GitHub (Oct 18, 2021): Many thanks!
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-python-kokarare1212#5
No description provided.