Så kan jeg da lige smide hele koden som den ser ud nu :)
procedure TForm1.Button1Click(Sender: TObject);
var
TheLength: LongInt;
begin
if OpenDialog1.Execute then begin
Label3.Caption := OpenDialog1.Filename;
with Mediaplayer1 do begin
FileName := OpenDialog1.Filename;
Display := Panel1;
Open;
Timeformat := tfMilliseconds;
TheLength := MediaPlayer1.Length;
// StartPos := 10000;
// EndPos := 10100;
// thelength := thelength div 1000 div 60; //længden i min.
Label1.caption := IntToStr(thelength);
DisplayRect := Panel1.Clientrect;
// Play;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label2.Caption := IntToStr(Mediaplayer1.Position);
end;
procedure TForm1.MediaPlayer1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
var
h, m,s, hund : integer;
start, stop : String;
f : real;
begin
DoDefault := false;
Start := \'00:00:04:05\';
Stop := \'00:00:09:03\';
case Button of
btPlay :
begin
h := StrToInt(copy(Start,1,2)) * 60 * 60 * 1000;
m := StrToInt(copy(Start,4,2)) * 60 * 1000;
s := StrToInt(copy(Start,7,2)) * 1000;
hund := StrToInt(copy(Start,10,2));
with MediaPlayer1 do begin
StartPos := 0;
StartPos := h + m + s + hund;
end;
h := StrToInt(copy(Stop,1,2)) * 60 * 60 * 1000;
m := StrToInt(copy(Stop,4,2)) * 60 * 1000;
s := StrToInt(copy(Stop,7,2)) * 1000;
hund := StrToInt(copy(Stop,10,2));
with MediaPlayer1 do begin
EndPos := 0;
EndPos := h + m + s + hund;
end;
Caption := Format(\'Start %d, Stop %d\', [MediaPlayer1.StartPos, MediaPlayer1.EndPos]);
MediaPlayer1.Play;
end;
btPause:
begin
MediaPlayer1.Pause;
end;
btStop:
begin
MediaPlayer1.Stop;
end;
end;
end;
Hele eksemplet kan hentes fra
http://home1.inet.tele.dk/j-cgeert/jb.zipSnowball