Daniel Gillet wrote:
my_playlist = chain(intro, repeat(main_theme), ending)
player.queue(my_playlist)
if this just takes the next
element in the my_playlist iterator, we will never reach the ending song
That's not how you would do that. You'd do it like this:
def my_playlist():
yield intro
while game_is_running():
yield main_theme
yield ending
player.queue(my_playlist())
When the game ends it will need to call player.next_source()
to jog it into action, but the iterator will take care of
breaking out of the loop.
If I think about a Media Player, the usual functionalities are : play
once, repeat one song, repeat the whole playlist.
The "usual" things provided by an API are not always the most
appropriate ways to do things in Python. Given that playlists
are iterators, all three of the above are trivial to express:
player.queue(song)
player.queue(repeat(song))
player.queue(cycle(song_list))
I guess that the current behaviour of
discarding a Source once it is played is actually surprising to the
user. I would then make this an option, but not the default.
It's certainly surprising in a Python context -- one would
expect Sources to behave like any other Python object and
stay around until they're no longer referenced, unless
something is explicitly done to dispose of them.
--
Greg
--
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.