help with wx.PyTimer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

help with wx.PyTimer

pythonist12
Hello.
Can anyone help me with this code.
The idea is to play multiple files with pygame, the play() function work find with single file
I can play, pause, unpause and replay a playback  , but when I try to run a lots of playback the wx do not respond

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

test2.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with wx.PyTimer

Tim Roberts
[hidden email] wrote:
> Hello.
> Can anyone help me with this code.
> The idea is to play multiple files with pygame, the play() function
> work find with single file
> I can play, pause, unpause and replay a playback  , but when I try to
> run a lots of playback the wx do not respond

Of course it does.  Look at your code in OnOk:

                for i in files :
                        play(i)
                        while pygame.mixer.music.get_busy():
                                time.sleep(0.05)

You start playing file #1.  Then, you sit in that loop waiting uselessly
until the mixer is idle (meaning until the playback is finished).  Then
you start playing file #2, and wait for it to finish.  You have
specifically asked for one file at a time here.  Further, because this
is in your OnOk handler, your user interface will be totally
non-responsive until ALL the files have finished and this routine
returns.  Remember that your message loop cannot handle any messages
until a handler returns.

Pygame is naturally asynchronous, but you are intentionally suppressing
that.  If you want to start three files playing at once, then just do that:

                for i in files:
                        play(i)

Don't do any waiting.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with wx.PyTimer

pythonist12
Thank you for your reply .
But when I did what you said the pygame start directly playing the last file in the list
but the first two files did not play at all
I want to play the three files in a sequence can I do that .

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with wx.PyTimer

Tim Roberts
[hidden email] wrote:
> Thank you for your reply .
> But when I did what you said the pygame start directly playing the
> last file in the list
> but the first two files did not play at all
> I want to play the three files in a sequence can I do that .

Oh, I thought you wanted to play them all at once.  The
pygame.mixer.music interface will only play one file at a time.  If you
want to queue up a second file to play after the first one finishes, you
can use pygame.mixer.music.queue, but the queue is only one file deep.
You can try set_endevent to get a callback when the music finishes, but
I don't know if that means "after every file" or "after ALL files".

To get fancier than that, you will have to use the pygame.mixer.Sound
objects instead of the mixer.music interface.  That doesn't support MP3,
so you'll have to convert the files to wave files.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with wx.PyTimer

pythonist12
Thank you for your help .
realy I can't use wav I need to use mp3 only .

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with wx.PyTimer

Tim Roberts
[hidden email] wrote:
>
> Thank you for your help .
> realy I can't use wav I need to use mp3 only .

You're not thinking creatively.  There are tools available to convert
MP3 to WAV on the fly.  You don't have to alter your library of tunes.

As I see it, you have three choices.

1. Convert your MP3s to WAVs on the fly and use pygame.mixer.Sound
2. Decompress the MP3s on your own and feed the buffers to
pygame.mixer.Sound
3. Choose a framework other than pygame

In any case, this no longer has anything to do with wxPython, so your
answers probably lie on another list.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...