[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Mediaplayer and AVI playing on a Form

If using TMediaPlayer and setting the display of a video to a panel on a form everything works fine ... until the playing of the video is finished (or paused). Then if you switch between the applications or drag a window over the display area it doesn't get redrawn properly. Like the effect if Windows freeze and you move some windows around. Is there a solution to this that is fast?

I don't want to use Mediaplayer.step or something like this to redraw it every time and I don't also want to use ActiveMove/Windows Media Player because it needs a seperate install.

Thank you for your answer.

regards, Bostjan.
0
kolarb
Asked:
kolarb
1 Solution
 
rwilson032697Commented:
What you could do is when the player has finished playing, copy the contents of the window to a bitmap, the redraw that back to the window whenever it gets a WM_PAINT message (of cource you would want to do nothing in the message handler while the mediaplayer was playing!)

Cheers,

Raymond.
0
 
kolarbAuthor Commented:
Well I thought of that but implementation bugs me. Since I'm giving away at least 400 points some code would be nice.

Thanks!
0
 
men xinCEOCommented:
i want to know...
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
rwilson032697Commented:
OK, here are some snippets to help out (to make life really easy here, lets use a TPaintBox to display the AVi in - it means we don't need to mess with any new components)!

var
  TheBitmap : TBitmap;
  PlayingAVI : Boolean;
....
  TheBitmap := TBitmap.Create;

In the OnNotify event of your TMediaPlayer do this:

with MediaPlayer1 do
  if NotifyValue = nvSuccessful then
    begin
      TheBitmap.width := ThePaintBox.width;
      TheBitmap.height := ThePaintBox.height;
      TheBitmap.Canvas.Draw(PaintBox1.Canvas);
      PlayingAVI := False;
    end;

In the OnPaint event of the paint box do this:

  if not PlayingAVI then
    PaintBox1.canvas.draw(TheBitmap.Canvas);

Does that sort things out a bit for you?

Cheers,

Raymond.    
0
 
kolarbAuthor Commented:
Great, thank you.

Let me test this (sorry, on monday) and notify you later.

Could you please answer me this question in the meantime: What if there is something in front of the PaintBox - like a Button for example. Does it too get captured on the bitmap?

cheers,
Bostjan
0
 
rwilson032697Commented:
Not 100% sure if it won't as the paintbox's canvas is really overlaid on top of the component that owns it. To make certain you could put the paintbox in a panel of its own which has a canvas proper... Try it!

Cheers,

Raynond.
0
 
IndefreiCommented:
Listening..
0
 
kolarbAuthor Commented:
sorry, forgot to accept it..
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now