Thread: ogg

    #1
  1. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    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
  4. #3
  5. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    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

IMN logo majestic logo threadwatch logo seochat tools logo