Question

I am playing a video using IVMRWindowlessControl9 i.e. WindowlessControl w/ VMR-9. When I initially had difficulty setting the video up, I noticed many examples found online had this piece of code in the Window's Paint handler:

IntPtr hdc = e.Graphics.GetHdc();
int hr = 0;
hr = windowlessCtrl.RepaintVideo(this.Handle, hdc);
e.Graphics.ReleaseHdc(hdc);

My video is playing correctly yet I do not have the above code. What does the above code do and is there a point in using it?

Was it helpful?

Solution

In most cases you don't need to repaint the video explicitly because the video renderer does it automatically. Yes, if the hosting window needs - for any reason - to request forced replaint, such as as part of WM_PAINT window message handler, then RepaintVideo method is here at your service.

See more on MSDN, VMR Windowless Mode:

During playback, the application should notify the VMR of the following Windows messages:

WM_PAINT: Call IVMRWindowlessControl::RepaintVideo to repaint the image.

OTHER TIPS

As to what it does:

  • if the video is being drawn using a destination colour key, then it paints the key colour into the destination window.

  • if the image is letterboxed, or part of it falls on another monitor, it will paint the parts that are not covered by the image.

So it may be that you won't see any difference if it is not done at all, if none of these things apply.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top