Hi Mitchell,
I was curious about this, because I'm not very faimilar with the
pyglet.media module myself either. I gave it a try with some tiny *.wav
files (since I don't have avbin), and it errored out due to the sources
already being queued to the player on the second loop. This might only be
because my wav files were so small, so using static sources
(streaming=False) may not be necessary for you.
import os, sys, random, pyglet
from random import shuffle
song1 = pyglet.media.load('jump.wav', streaming=False)
song2 = pyglet.media.load('pickup.wav', streaming=False)
song3 = pyglet.media.load('laser.wav', streaming=False)
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
if __name__ == "__main__":
beatz()
pyglet.app.run()
On Friday, June 17, 2016 at 6:45:15 AM UTC+9, Mitchell Barton wrote:
>
>
> 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.