title: on_player_eos event not working when trying to play through a list of mp3 files with Pyglet
body: <p>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</p>
  
  <pre><code>import os, sys, random, pyglet
  from random import shuffle
  
  song1 = pyglet.media.load('beats/breathe.mp3', streaming=False)
  song2 = pyglet.media.load('beats/everything.mp3', streaming=False)
  song3 = pyglet.media.load('beats/jazz.mp3', 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
  
  pyglet.app.run()
  </code></pre>
  
  <p>I have also tried replacing the 'player.on_player_eos = on_player_eos' with </p>
  
  <pre><code>player.push_handlers(on_player_eos)
  </code></pre>
  
  <p>But it doesnt seem to do anything either. Any help appreciated.</p>
  
  <p>UPDATE:</p>
  
  <p>I was able to get this to work by simply adding 'streaming=False' to each song variable. Streaming sources in pyglet can only be queued once on a player object, while static sources can be queued as many times as you want. </p>
  
  <p>With recognizing the event 'on_player_eos', I also wasn't aware of the pyglet event loop. In order for pyglet to pick up the events I wanted it to, the code below had to be run.</p>
  
  <pre><code>pyglet.app.run()
  </code></pre>
  
  <p>This fixed my problems.</p>