Hi Greg, Thanks for the great feedback and discussion. I must say I'm glad we're talking about things like PlayList and not about video not playing correctly! :)
I see your point and it's a great one. I can better imagine how one could make any sort of playlists. I like the idea and I'm trying to figure out a couple of things. 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. I can see solutions to this problem, but I was wondering how you were envisioning that. Also I think we should let users write code like the following: 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. Dan On Sun, Nov 26, 2017 at 1:06 AM, Greg Ewing <[email protected]> wrote: > 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 a topic in the > Google Groups "pyglet-users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/to > pic/pyglet-users/ah2I54BSrZg/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- 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.
