wx.MediaCtrl problem

hi,

I am using MediaCtrl in a small video-tracking project. It is based on the MediaCtrl demo in the wxPython docs with only slight mods. What it does is to create an instance of MediaCtrl with defaults and the parent is a wx.Window that is within a wx.Frame. I then create a device context as follows:

self.mc.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)

def OnRightDown(self, evt):

dc = wx.WindowDC(self.mc)#self.mc is the MediaCtrl

dc.SetBackground(wx.TRANSPARENT_BRUSH)

dc.SetBrush(wx.TRANSPARENT_BRUSH)

print “Colour is :”,dc.GetPixel(evt.GetX(),
evt.GetY())

I have encountered the following problems:

1)For the program to get the correct pixel value, I have to first open Windows Media Player and start the video there. Otherwise, the colour gotten is ALWAYS (16,0,16).

2)When I move the Frame while the video is paused, the MediaCtrl is left behind such that moving the frame results in only a part of the video being seen (if I move the frame further, I don’t even see any part of the video). This also does not happen if WMP is open and playing the video.

3)I have been unable to scale the MediaCtrl so that it fits exactly in the wx.Window whose size is set to (500,400)

4)I want the slider used for seeking to be enabled immediately the video is loaded such that I use the slider to select where I want the video to start playing before clicking on the play button.

please help me out here. The program is giving me sleepless nights! My box a Cyrix clone with cpu speed of 800Hz (though I dont think this is an issue. I have tried the prog on different computers with the same outcome). I am using wxPython version 2.6.3.3 on Python 2.4. Platform is Windows 2000.

···

How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

simon kagwe wrote:

hi,
I am using MediaCtrl in a small video-tracking project. It is based on the MediaCtrl demo in the wxPython docs with only slight mods. What it does is to create an instance of MediaCtrl with defaults and the parent is a wx.Window that is within a wx.Frame. I then create a device context as follows:
self.mc.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
def OnRightDown(self, evt):
             dc = wx.WindowDC(self.mc)#self.mc is the MediaCtrl
             dc.SetBackground(wx.TRANSPARENT_BRUSH)
             dc.SetBrush(wx.TRANSPARENT_BRUSH)
             print "Colour is :",dc.GetPixel(evt.GetX(), evt.GetY())
I have encountered the following problems:
1)For the program to get the correct pixel value, I have to first open Windows Media Player and start the video there. Otherwise, the colour gotten is ALWAYS (16,0,16).
2)When I move the Frame while the video is paused, the MediaCtrl is left behind such that moving the frame results in only a part of the video being seen (if I move the frame further, I don't even see any part of the video). This also does not happen if WMP is open and playing the video.

I think that both of these are related to how video is handled in Windows. IIUC the video is not handled the same as the other windows. The video data is in another "layer" that is flushed directly to the GPU buffer and is not kept in the same buffers as the rest of the pixels on the screen. Hence when you use a device context on the window it is not interacting with the same pixels that you see.

When you also run WMP, then Windows is probably giving it the special treatment and forcing the other video view to run in the old slow way by using the actual window buffer for display.

3)I have been unable to scale the MediaCtrl so that it fits exactly in the wx.Window whose size is set to (500,400)

In what ways have you tried to do it?

4)I want the slider used for seeking to be enabled immediately the video is loaded such that I use the slider to select where I want the video to start playing _before_ clicking on the play button.

The ActiveX control used for showing the video loads in a asynchronous manner, and so it has not fully loaded the video and is not ready for processing until sometime after you call Load. So basically the display needs to stay in a default state at least until it is ready to proceed, and it sends an event to let you know. After that then I would expect that you should be able to use Seek to position the video, although the control may still require you to begin and then stop playback for things to be fully initialized.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!