Code exits immediately with no playback on Linux
nhansendev opened this issue · 2 comments
When I try to run example code (see below) it immediately exits without playing the file. There are no error messages, and if I check the playback duration it provides a value as expected (Ex: 157.14). I am running Linux Mint 19.3 Cinnamon, Kernel 5.4.0-100-generic. Any thoughts on why this would not be working, or what to check?
from just_playback import Playback
playback = Playback('/home/user/Documents/song.mp3')
playback.play()
Hi Obliman,
When the play() method is called audio playback begins in another thread and the main thread continues execution. When the main thread exits, the playback thread also exits. So your program terminates before your audio file starts playing. Your code should be
from just_playback import Playback
playback = Playback('/home/user/Documents/song.mp3')
playback.play()
while playback.active:
pass
I see, thank you for the clarification.
It might help to have that mentioned in the Usage section since I assumed that I could just use the code as it was written there.
Also, what do you think about adding a blocking, and/or daemon argument to play()? That way there is a more streamlined way to wait for the sound to finish playing.