Daniel Gillet wrote:
If playlists are iterators, it means that
player.queue takes as an argument an iterator. But player.queue(song)
does not qualify anymore, as song is a Source and not an iterator.
There are a couple of ways to handle that. One is to have
player.queue() inspect its argument and do different things
depending on whether it's a Source instance or not.
Another is to have two methods, such as player.queue_source()
and player.queue_playlist().
There are pros and cons either way. The single method is
less to remember and maybe slightly easier to document,
but two separate methods is friendlier towards duck-typing
and makes the intent of the code clearer to the reader.
I'll leave it up to you to decide.
player.queue(song1)
player.queue(song2)
The user would probably expect that the songs are all played once and
> then the player stops once all the songs have been played.
Does this mean that the Player has some sort of default PlayList which
would be similar to a list where queuing songs mean you're appending
them to the list? And obviously the Player would then get an iterator
from that list. If on the other hand the client code provides an
iterator to the player.queue method, then we just use that one to get
the Sources.
I don't think that's quite right. If the user does this:
player.queue(song1)
player.queue(some_iterator)
player.queue(song2)
it should play song1, then all the songs returned by the
iterator, then song2.
I think what you need is an internal list of "things to be
played", each of which can be either a Source or an iterator,
and have it work its way through that.
If it would make anything simpler, you could wrap a single
Source in a one-element sequence before putting it in the
list, so that all the things in the list are iterables.
--
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.