Autor Beitrag
Hoellenwesen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 01.02.04 14:43 
Hallo zusammen,

wie kann ich bei einer MP3 die spieldauer anzeigen lassen, sobald sie gestartet wurde? ich benutzte zum abspielen die MediaPlayer kompo.
ich hab mir schonmal etwas code besorgt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var x : Integer; 
begin 
x := MediaPlayer1.Length div 1000;
Label1.Caption := IntToStr(x div 60)+':'+IntToStr(x mod 60); 
end;



aber wenn bei diesem code die MP3 z. B. 5 sekunden läuft, dann zeigt der als zeit 0:5 an, ich möchte aber, dass der 00:05 anzeigt. wie mache ich das. wäre nett, wenn ihr mir code posten könntet ;-)

Vielen Dank im voraus
MfG

Hoellenwesen

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 01.02.04 14:55 
So sollte das in etwas gehen. Kleinere Fehler nicht ausgeschlossen, hab das jetzt nicht getestet
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var tmpstr : string;
[...]
tmpstr:='';
if (x DIV 60)<10 then
  tmpstr := '0' + InttoStr(x DIV 60) + ':'
else tmpstr := InttoStr(x DIV 60) + ':';

if (x mod 60)<10 then
  tmpstr := tmpstr + '0' + inttostr(x mod 60)
else tmpstr:=tmpstr + inttostr(x mod 60);
Label1.Caption:=tmpstr;

_________________
We are, we were and will not be.
Hoellenwesen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 01.02.04 15:09 
hmm

irgendwie geht das nicht, die zeit läuft dann nicht weiter, da steht nur eine lange zahl z. B. 17845:44, aber die zeit läuft halt nicht.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 01.02.04 16:43 
das ist doch auch klar...
mediaplayer1.length gibt doch auch nur die Länge des Files an. Das hat ja nix damit zu tun, wie lange das schon läuft...
Warum die Zahl so groß ist, weiss ich jetzt auch nicht so genau, hast du auch x wieder erst durch 1000 geteilt..?

_________________
We are, we were and will not be.
Hoellenwesen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 01.02.04 19:13 
Hallo

sorry, denn habe ich das verwechselt. ja ich habe es durch 1000 geteilt, nunja. weißt du denn, wie ich das mache, dass der mir anzeigt, wie lang die mp3 schon läuft?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 01.02.04 20:12 
Da würde ich mir mal die Eigenschaft mediaplayer1.position genauer angucken. Die liefert die Position im file ab, an der man grade ist. Die Aktualisierung kann man dann z.B. über einen Timer machen. D.h. Timerintervall auf 1000ms, und im OnTimerEvent die Anzeige aktualisieren, wie in der Prozedur oben.

_________________
We are, we were and will not be.
Hoellenwesen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 01.02.04 20:25 
Danke,

ich werde mir das mal genauer angucken!
wenn es nicht klappen sollte, denn melde ich mich hier nochmal ;-)

Vielen Dank für deine Hilfe
MfG

Hoellenwesen