-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kivy.core.audio
- SoundLoader: support URLs as source, error handling and timeout
#8591
Comments
kivy.core.audio
- SoundLoader: support URLs as source, error handling and timeout
The issue with pause/play causing the audio to go to the timestamp specified by seek(position) and then restart from the beginning may have to do with the play method having an extra step of seek(0) at the end? I can't quite figure out why this step is there. If you use ffpyplayer directly the toggle_pause() method works exactly like you expect -- as a toggle, there is no need to play around with seek() at all as it remembers the time stamp. EDIT: If in my own code I build in a delay (e.g. via Clock.schedule_once) between play and seek(position) by triggering the seek() via the callback then it works fine -- I guess timing issues are causing the extra "seek(0)" to fall after my own code is doing seek(position)? Seems like a bug to me? Code snippet from audio_ffpyplayer.py:
|
Is your feature request related to a problem? Please describe.
While e.g. ffpyplayer supports URLs as source for the audio, it doesn't appear to be fully supported within Kivy:
There is no handling in the audio_ffpyplayer.py code for fatal errors by ffpyplayer such as "HTTP error 403 Forbidden". It can't be caught by a try/except and will cause the app to crash (this may be a bug but perhaps it was not the intention for us to use URLs here so have opened as feature request).
Here's an example:
The following URL causes an error for ffpyplayer (note: this URL works fine when opened in browser, and the audio can be played in-browser and downloaded as MP3):
from ffpyplayer.player import MediaPlayer
ffplayer = MediaPlayer("https://www.buzzsprout.com/1984146/14368896-january-24-2024.mp3")
Output:
If you try it with SoundLoader it crashes the app when the play() method is applied. You can put try/except around the load and play but this will not help.
sound = SoundLoader.load("https://www.buzzsprout.com/1984146/14368896-january-24-2024.mp3")
if sound:
sound.play()
Output:
I have also encountered issues with pause/play for URLs: the audio is resumed at the right timestamp but then it restarts again from the beginning. For files it works perfectly for me. I couldn't see reasons/errors for this behaviour so maybe the URL causes issues with pause/play on a deeper level (EDIT: See my comment below).
Describe the solution you'd like
A clear and concise description of what you want to happen.
Full support for URLs as source for SoundLoader:
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Downloading the file and then playing it via SoundLoader doesn't fit my use case (my intention was to provide a "play" button for podcasts, which can be lengthy.) I have considered going outside of Kivy but that would be out-of-scope for me at this time.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: