471,353 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

Using wxMediaCtrl in wxPython

2
Hi There
I will like to play back an mpeg video file using wxPython's MediaCtrl class. The video controls are grayed out and the file doesnt play.

Any suggestions would be welcome
Heres a sample of the code

Thanks
Chaven
Expand|Select|Wrap|Line Numbers
  1. #==================================================
  2. import wx 
  3. import wx.media
  4.  
  5. class MyFrame(wx.Frame): 
  6.     def __init__(self,parent,title): 
  7.         wx.Frame.__init__(self,parent,-1,title,pos=(150,150),size =(640, 480),style=wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
  8.         self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
  9.         panel = wx.Panel(self,size=(350,200)) 
  10.          video = wx.media.MediaCtrl(panel,-1,fileName ="V003.mpg",pos=wx.Point(100,50),size=wx.Size(320,240))
  11.  
  12.         video.ShowPlayerControls(flags = wx.media.MEDIACTRLPLAYERCONTROLS_STEP)                
  13.         video.Play()
  14.  
  15.     def OnCloseWindow(self,event): 
  16.         self.Destroy() 
  17. class MyApp(wx.App): 
  18.     def OnInit(self): 
  19.         frame = MyFrame(None,'Form1') 
  20.         frame.Show(True) 
  21.         return True 
  22. app=MyApp(redirect=True) 
  23. app.MainLoop()
Aug 23 '07 #1
3 6293
bartonc
6,596 Expert 4TB
You probably lack the codec or it is not being found. Have you tried just playing a native format (.wmv on Windows, etc)?
Aug 23 '07 #2
bartonc
6,596 Expert 4TB
You probably lack the codec or it is not being found. Have you tried just playing a native format (.wmv on Windows, etc)?
Another possibility is that the file is not being found. Is the moving in the same directory as you wxPython app?
Aug 23 '07 #3
bartonc
6,596 Expert 4TB
This works on my system:
Expand|Select|Wrap|Line Numbers
  1. import wx 
  2. import wx.media
  3.  
  4. class MyFrame(wx.Frame): 
  5.     def __init__(self,parent,title): 
  6.         wx.Frame.__init__(self, parent, -1, title, pos=(150,150), size=(640, 480),
  7.                           style=wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
  8.         self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
  9.         panel = wx.Panel(self,size=(350,200)) 
  10.         video = wx.media.MediaCtrl(panel, -1, fileName=r"D:\My Documents\My Videos\Who_Let_The_Dogs_Out.wmv",
  11.                                    pos=wx.Point(100,50),size=wx.Size(320,240))
  12.  
  13.         video.ShowPlayerControls(flags = wx.media.MEDIACTRLPLAYERCONTROLS_STEP)                
  14.         video.Play()
  15.  
  16.     def OnCloseWindow(self,event): 
  17.         self.Destroy()
  18.  
  19. class MyApp(wx.App): 
  20.     def OnInit(self): 
  21.         frame = MyFrame(None,'Form1') 
  22.         frame.Show(True) 
  23.         return True 
  24. app=MyApp(redirect=True) 
  25. app.MainLoop()
Aug 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Equis Uno | last post: by
2 posts views Thread by Axium Computer Services | last post: by
15 posts views Thread by Grant Edwards | last post: by
1 post views Thread by James Stroud | last post: by
3 posts views Thread by Kenneth McDonald | last post: by
8 posts views Thread by John Salerno | last post: by
2 posts views Thread by Marco | last post: by
4 posts views Thread by stef | last post: by
1 post views Thread by Marcin Kalicinski | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.