wx.MediaCtrl how play a streaming media audio?

Godson Gera godson.g at gmail.com
Thu Jan 3 09:53:15 PST 2008


Hi

I am trying to use wx.MediaCtrl on windows for playing http audio stream..
The Play() method on MediaCtrl is failing :( I've tried with different
streams with no luck. Can you please tell me whats going wrong or show me an
example of how to play streaming media?

#!/usr/bin/python

import wx
import wx.media
class MediaFrame(wx.Frame):
    def __init__(self,id,title):
        wx.Frame.__init__(self,None,id,title,)
        self.panel =3D wx.Panel(self)
        try:
            self.mc =3D wx.media.MediaCtrl(self.panel,szBackend=3D
wx.media.MEDIABACKEND_DIRECTSHOW)

        except NotImplementedError:
            print "media control not found"


        self.Bind(wx.media.EVT_MEDIA_LOADED,self.OnMediaLoaded)
        self.playbtn =3D wx.Button(self.panel,-1,"Play",)
        self.Bind(wx.EVT_BUTTON,self.OnPlay,self.playbtn)
        wx.CallAfter(self.DoLoadMedia)


    def DoLoadMedia(self):
        print "Called"
        self.playbtn.Disable()
        if not self.mc.LoadFromURI("http://192.168.1.3:8000/ices"):
            print "Failed to load media"
        else:
            self.mc.SetInitialSize()
            self.playbtn.Enable()


    def OnMediaLoaded(self,):
        print "media Loaded"
        self.playbtn.Enable()


    def OnPlay(self,evt):
        print "Onplay called"
        if not self.mc.Play():
            print "Failed to play"
        else:
            self.mc.SetInitialSize()

if __name__=3D=3D"__main__" :
    app =3D wx.PySimpleApp()
    f =3D MediaFrame(-1,"testclient")
    f.Show(True)
    app.MainLoop()


-- =

Godson Gera,
http://godson.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200801=
03/9250cf17/attachment.htm


More information about the wxpython-users mailing list