2010. január 7., csütörtök

How to play a video on program start


Problem/Question/Abstract:

I'm writing a program that plays an AVI when it starts and placed the mediaplayer.play command on the FormActivate event. The problem is that the movie starts playing before all objects have been painted and after all objects are painted the movie blinks. Is there a way to control that the movie starts after the form has been painted completely and not before?

Answer:

You could use e.g. a private variable of type boolean and a timer:

procedure TForm1.FormActivate(Sender: TObject);
begin
  if not AviPlayed then
    Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  {play your avi here}
  AviPlayed := True;
end;

Nincsenek megjegyzések:

Megjegyzés küldése