开发者

Code for playing video in wx.Media after the wmv file is loaded

I am a newbie in wxPython and I have to write a code that can immediately start playing a video after I load the file. I have been going through a lot of forums tried to implement 10 - 20 codes, but the wx.media is not playing the video file at all. I am able to load the file but not play it.

I need a simple code in which I will manually enter the path name of the video file and after this file is loaded it should start playing.

I am using windows XP, Python 2.7 and wxPython for Python 2.7.

I would be very grateful to all of you if you could help me on this one.

Following is the code that I am using to load() and then play() the file. Still it is not working.

import wx 
import wx.media

class TestPanel(wx.Panel):

    def __init__(self, parent):

        wx.Panel.__init__(self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)

        # Create some controls
        try:
            self.mc = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER)
        except NotImplementedError:
            self.Destroy()
            raise
        self.mc.Load(r"C:\Documents and Settings\N1002401B\Desktop\test1.wmv")
        #self.slider.SetRange(0, self.mc.Length())
        #folder, filename = os.path.split("C:\Documents and Settings\N1002401B\Desktop\test1.wmv")
        self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnPlay)
    def OnPlay(self,evt):
        self.mc.Play()

app = wx.App(0)

frame = wx.Frame(None)
panel = TestPanel(frame)
开发者_StackOverflowframe.Show()

app.MainLoop()

Thanking you.


You can find a tutorial for the wx.media module here.

You have to call Load(path) and Play() on your MediaCtrl object.

It would be a good idea for future posts to include a small snippet of your code, so that we can know what exactly you have tried.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜