unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MPlayer, StdCtrls, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button2: TButton;
    MediaPlayer1: TMediaPlayer;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label4: TLabel;
    TrackBar1: TTrackBar;
    Timer1: TTimer;
    Button1: TButton;
    Label3: TLabel;
    Button6: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private declarations }
  public

   end;



var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button3Click(Sender: TObject);
begin
  Mediaplayer1.FileName:= 'Miedziana_Gora.MPG';
  with mediaplayer1 do
  begin
   Open;
   MediaPlayer1.TimeFormat := tfMilliseconds;
   displayrect:=Rect(0,0,panel1.Width,panel1.Height);
   play;
   notify:=true;
 end;
    trackbar1.Max:=Mediaplayer1.Length;
end;

procedure TForm1.Button4Click(Sender: TObject);

var
  dl: LongInt;
begin
 // można odczyta numeru formatu czasu, aby odpowiednio go zinterpretowac
 label3.Caption:=Inttostr(ord(Mediaplayer1.timeformat));
 dl := MediaPlayer1.Length div 1000;  //zamiana na sek
  //label1.Caption:=inttostr(dl);
  Label2.Caption := IntToStr(dl mod 60)+' sek, '
  +IntToStr(dl div 60)+' min, '
  +IntToStr(dl div 3600)+' godz';
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
   Mediaplayer1.Close;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 //jesli utwór jest odtwarzany (status=playing) to wyswietl
 //czas odtwarzania i przesuń suwak na paseku progressbar
  if Mediaplayer1.Mode=mpPlaying then
  begin
    Trackbar1.Position:=Mediaplayer1.Position;
    Label4.Caption:='Czas odtwarzania='+InttoStr(Mediaplayer1.Position)+'ms';
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 Label3.Caption:=Inttostr(MediaPlayer1.Frames);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 Mediaplayer1.Pause;
end;


end.
