Jeg har brug for at kunne afspille videofiler (mov, avi, mpeg o.l.) i et
panel eller lign.
Mht. avi-filer, har jeg fundet følgende kode, men det virker ikke! Hvad er
der galt?
Og hvordan spiller jeg QuickTime Mov-filer?
Og MPeg?
Og andre?
Hej fra Lars
Her er avi-koden:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MPlayer, StdCtrls, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button2: TButton;
Button3: TButton;
MediaPlayer1: TMediaPlayer;
Button1: TButton;
TrackBar1: TTrackBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
TheLength: LongInt;
begin
With MediaPlayer1 do
Begin
DeviceType := dtAVIVideo;
TimeFormat := tfFrames;
Open;
FileName := 'D:\Film\Små-film\Firs_Aar_Tilbage.avi';
TrackBar1.Max := Frames;
TheLength := Length;
Display := Panel1;
DisplayRect := Rect(10,10, Panel1.Width-20,Panel1.Height-20);
Play;
End;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
If (Sender As TButton). Caption = 'Pause' Then
(Sender As TButton). Caption := 'Continue';
If (Sender As TButton). Caption = 'Continue' Then
(Sender As TButton). Caption := 'Pause';
MediaPlayer1.Pause;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
MediaPlayer1.Stop;
Panel1.Refresh;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
With MediaPlayer1 do
Begin
StartPos := TrackBar1.Position;
Play;
End;
end;
end.
|