You need to use the clock.schedule_once() method if I remember right.

stream = pyglet.resource.media(mediaFile)
stream.play()
pyglet.clock.schedule_once(pyglet.app.exit, stream.duration)
pyglet.app.run()



On Tue, Apr 2, 2013 at 3:57 AM, Itzik Hanoch <[email protected]> wrote:

> Hi guys,
>
> Im new to pyglet (so far it looks like a great library) and im trying to
> do the following:
>
> 1)Have a background music which will play (unless stopped somewhere in the
> code)
>
> 2)Ability to add  more sounds over this background music
>
> 3)Ability to add more background sounds that will continue to play always
>
> this is what i have so far (Very simple):
>
> *def parse(fd):*
>
> *    for line in fd:*
>
> *        for word in line.split():*
>
> *            if(word == "word"):*
>
> *                s1 = pyglet.resource.media("lines.mp3");*
>
> *                s1.play()*
>
> *                s2 = pyglet.resource.media("look.mp3")*
>
> *                s2.play()*
>
> *                pyglet.app.run()       <-----Cant get pass this*
>
> *
> *
>
> *def filehandle(filename):*
>
> *    while(True):*
>
> *        print "parsing"*
>
> *        fd = open(filename,'r+')*
>
> *        parse(fd)*
>
> *        fd.close()*
>
> *
> *
>
> *if __name__ == '__main__':*
>
> *    print "Please enter file name: ";  *
>
> *    filename = raw_input()*
>
> *    filehandle(filename)*
>
> *    sys.exit()*
>
> The thing is, as mentioned, i cant get pass the *pyglet.app.run() *since
> it will wait for the song to end and then perform another loop iteration.
>
> (never mind i am always adding the same sounds, i just want to learn how
> this can be done)
>
> How could this be done?
>
> Thanks!
>
>
>  --
> 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 http://groups.google.com/group/pyglet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
E-ThoughtDumpyard <http://www.onloop.net/>

-- 
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 http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to