Reproduzir um vídeo AVI em um Form no Delphi
- Crie um novo projeto. Este já deverá ter o Form1; - Adicione um novo Form (Form2); - Coloque, no Form1, um TMediaPlayer (paleta System) e um botão; - Altere o evento OnClick do botão como abaixo: procedure TForm1.Button1Click(Sender: TObject); begin with MediaPlayer1 do begin FileName := 'c:\VIDEO.avi'; Open; { Ajusta tamanho do Form } with MediaPlayer1.DisplayRect do begin Form2.ClientHeight := Bottom - Top; Form2.ClientWidth := Right - Left; end; Display := Form2; Form2.Show; Play; end; end;
Em vez de ajustar o Form ao vídeo, podemos ajustar o vídeo ao Form. Para isto troque o trecho with..end; por MediaPlayer1.DisplayRect := Form2.ClientRect;