down votefavorite
<http://stackoverflow.com/questions/37869779/on-player-eos-event-not-working-when-trying-to-play-through-a-list-of-mp3-files#>
I'm trying to shuffle a list of mp3 files and then play through them with
pyglet. Once the player runs out of sources I want to re-shuffle the list,
and then play through them again. This process would happen infinitely. I
have been able to get pyglet to play through the sources once, but the
on_player_eos event is never fired when I run out of sources. I'm not sure
exactly what I am doing wrong, or if I am approaching it in the wrong way.
I've tried a couple ways of doing it, but have had no luck getting it to
work. Here is the code
import os, sys, random, pygletfrom random import shuffle
song1 = pyglet.media.load('beats/breathe.mp3')
song2 = pyglet.media.load('beats/everything.mp3')
song3 = pyglet.media.load('beats/jazz.mp3')
player = pyglet.media.Player()
# Play beatz
def beatz():
playlist = [song1, song2, song3]
shuffle(playlist)
player.queue(playlist[0])
player.queue(playlist[1])
player.queue(playlist[2])
player.play()
def on_player_eos():
print('repeating')
beatz()
player.on_player_eos = on_player_eos
I have also tried replacing the 'player.on_player_eos = on_player_eos' with
player.push_handlers(on_player_eos)
But it doesnt seem to do anything either. Any help appreciated.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.