unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    MediaPlayer1: TMediaPlayer;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public

  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Mediaplayer1.FileName:= 'ptak1.mp3';
  Mediaplayer1.Open;
  Mediaplayer1.Play;
  Label1.Caption:=ExtractFileName(Mediaplayer1.FileName);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Opendialog1.InitialDir:=GetCurrentDir;
  if Opendialog1.Execute then
  begin
   Mediaplayer1.FileName:= Opendialog1.FileName;
   Mediaplayer1.Open;
   Mediaplayer1.Play;
   label1.Caption:=ExtractFileName(Mediaplayer1.FileName);
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
var
  dl: LongInt;
begin
  //timeformat domyslnie w milisek
 // MediaPlayer1.TimeFormat := tfMilliseconds;
 { Czas trwania bieżącego utworu }
  dl := MediaPlayer1.Length div 1000;  //zamiana na sek
  Label2.Caption :=  IntToStr(dl div 3600)+' godz '+
                     IntToStr(dl div 60)+' min '+
                     IntToStr(dl mod 60)+' sek ';
end;

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

end.

