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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!)


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.

men xinCEOCommented:
i want to know...
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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)!

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

In the OnNotify event of your TMediaPlayer do this:

with MediaPlayer1 do
  if NotifyValue = nvSuccessful then
      TheBitmap.width := ThePaintBox.width;
      TheBitmap.height := ThePaintBox.height;
      PlayingAVI := False;

In the OnPaint event of the paint box do this:

  if not PlayingAVI then

Does that sort things out a bit for you?



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?

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!


kolarbAuthor Commented:
sorry, forgot to accept it..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.