tuffy / python-audio-tools

A collection of audio handling programs which work from the command line.
http://audiotools.sourceforge.net
GNU General Public License v2.0
249 stars 58 forks source link

Is there a way to enqueue audio files for playing? #73

Closed dentex closed 7 years ago

dentex commented 7 years ago

Hello. I'm trying to use this library as a back-end for a media player based on a Raspberry Pi and some physical hardware. No problem so far playing a single file:

audio_file = audiotools.open(MY_FILE_PATH)
output = audiotools.player.open_output('ALSA')
player = audiotools.player.Player(output, 'RG_NO_REPLAYGAIN', auto_enqueue_test())
player.open(audio_file)
player.play()

and then player.stop() or player.pause() as needed.

But what if I want to enqueue the subsequent audio files form the same directory?

I found that with audiotools.open_directory(MY_DIR_PATH) I can iterate over the audio files in that dir. So I used the auto_enqueue_test() function to do player.open(filename) on every item in the iterable. Every opening operation unfortunately stops the current playing mp3 and skips to the next...

Is there any solution?

PS: also, the next_track_callback it seems to be called as soon as I instantiate the player, not when the playing track is completed. But probably I'm missing something, because when I instantiate the player there's no audio playing...

Thanks for any help.

dentex commented 7 years ago

My mistake... player = audiotools.player.Player(output, 'RG_NO_REPLAYGAIN', auto_enqueue_test()) must be: player = audiotools.player.Player(output, 'RG_NO_REPLAYGAIN', auto_enqueue_test) (without the parenthesis).