|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
ogg
Im tring to create an mp3 player with ogg ( works great ) im also using wxPython module to add an interface on it.. but i have one question. How do i stop the audio from playing once the user hits the x button on your top right hand corner of the program? does wxWindow have a function for this? is there a tutorial for ogg that better explains more about it?
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#2
|
|||
|
|||
|
I do not know anything about the ogg API, but I presume there is a function to stop the audio. So the problem is how to call this function when the user exits your program. There are basically two ways to do this in wxPython:
1) You can associate a function with the close event of the main Frame, using EVT_CLOSE. 2_ Alternatively you could override the OnExit method of the class you derive from wxApp, to do the cleanup when the application exits. I think the first option is preferable. If you trap the close event then you must call the Frame's Destroy method to actually close the window. Here is a simple example: Code:
#!/usr/bin/env python
import wx
class Frame(wx.Frame):
def __init__(self, parent=None, id=-1,
pos=wx.DefaultPosition, title='Close Me'):
wx.Frame.__init__(self, parent, id, title, pos)
wx.EVT_CLOSE(self, self.onClose)
def onClose(self, event):
'''called when the Frame is closed by whatever means'''
wx.MessageBox('Bye Bye', 'Closing')
self.Destroy()
class App(wx.App):
def OnInit(self):
self.frame = Frame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app = App()
app.MainLoop()
if __name__ == '__main__':
main()
This will pop up a message box when the Frame is closed, either through clicking on the X or pressing Alt-F4 (on Windows). Dave - The Developers' Coach |
|
#3
|
||||
|
||||
|
ya thanx , i was reading about that but.. was thinking on what was the best way to implement the onexit function.. but by your example.. i got it working
thanx ( that part unlest ) now i just need to figure out the ogg part as i cant find a documentation on it with all its functions |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > ogg |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|