uses MPlayer;
function Dauer(MIDI: TFilename; twc: TWinControl): string;
const
mn = 60;
st = 3600;
var
Mediaplayer: TMediaplayer;
zt, hr: integer;
begin
Mediaplayer := TMediaplayer.create(twc);
Mediaplayer.parent := twc;
//------ eigentliche Routine ----------------------------------
Mediaplayer.Filename := MIDI;
Mediaplayer.open;
Mediaplayer.Timeformat := tfMilliseconds;
zt := round(Mediaplayer.Length / 1000);
hr := zt div st;
dec(zt, hr * st);
Result := Format('%.2d:%.2d:%.2d', [hr, zt div mn, zt mod mn]);
//-------------------------------------------------------------
Mediaplayer.close;
Mediaplayer.free;
end;
// Beispielaufruf
procedure TForm1.Button3Click(Sender: TObject);
begin
screen.cursor := crHourglass;
Label1.caption := Dauer('c:\nicesong.mid', self);
screen.cursor := crDefault;
end;