Autor Beitrag
Apollo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: So 03.08.08 09:04 
Hallo Delphianer,
mit diesem Code versuche ich herauszufinden wie Lang und welche Position ein Lied bei TMediaplayer hat:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.Timer12Timer(Sender: TObject);
var
TheLength: LongInt;  ThePos2:LOngint;
begin
 If Mediaplayerplayer1.Mode = mpplaying then
 begin
MediaPlayer1.TimeFormat := tfHMS;
TheLength := Videoplayer1.Length;
with HMSRec(TheLength) do 
begin
Label21.Caption := IntToStr(minutes); 
Label22.Caption := IntToStr(Seconds);
end;

 ThePos2 := Mediaplayer1.Position;
with HMSRec(ThePos2) do
begin
Label24.Caption := IntToStr(minutes); 
Label26.Caption := IntToStr(Seconds); 
end;
  end;
 end;
end.

Es läuft auch alles aber die Ergebnise stimmen nicht, z.B. 2 (min):215 (sec). Ich hoffe ihr könnt mir helfen.

mfg Apollo


Moderiert von user profile iconGausi: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 03.08.2008 um 10:13

_________________
Im Zweifelsfall immer das Richtige tun
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 03.08.08 09:13 
Wie sieht dem HMSRec genau aus? Ich denke, der Fehler liegt in diesem Typecast.

_________________
We are, we were and will not be.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 03.08.08 09:17 
Was sind das denn für Dateien MP3 ?
Damit hatte Ich auch immer Probleme das nicht die korrekte
Zeit angezeigt wird, liegt wohl wahrscheinlich an den verschiedenen Bitraten.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Apollo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: So 03.08.08 09:18 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  type
  HMSRec = record
  Hours: byte;
  Minutes: byte;
  Seconds: byte;
  NotUsed: byte;
   end;

_________________
Im Zweifelsfall immer das Richtige tun
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 03.08.08 09:28 
Ich denke immer noch, dass der Typecast schief geht. :mrgreen: Probier mal packed record für das HMS-Dings. Alternativ setz das Zeitformat auf Millisekunden und rechne selber um:
ausblenden Delphi-Quelltext
1:
2:
Seconds := TheLength MOD 60000;
Minutes := TheLength DIV 60000;

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

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: So 03.08.08 09:46 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
type
  HMSRec = packed record
  Hours: byte;
  Minutes: byte;
  Seconds: byte;
  NotUsed: byte;
   end;

{...}

procedure TForm1.Timer12Timer(Sender: TObject);
var
TheLength: LongInt;  ThePos2:LOngint;
begin

 If Mediaplayer1.Mode = mpplaying then
 begin


Mediaplayer1.TimeFormat := tfHMS;

TheLength := Mediaplayer1.Length;
with HMSRec(TheLength) do 
begin

Label21.Caption := IntToStr(thelength div 60000); 
Label22.Caption := IntToStr(thelength mod 60000); 
end;
   
 ThePos2 := Mediaplayer1.Position;
with HMSRec(ThePos2) do
begin
 
Label24.Caption := IntToStr(thepos2 div 60000); 
Label26.Caption := IntToStr(thepos2 mod 60000); 
end;
  end;
 end;

Leider futzt das auch nicht :autsch: :bawling: :crying: :eyes:

_________________
Im Zweifelsfall immer das Richtige tun
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 03.08.08 09:55 
Ähm, entweder du rechnest mit diesem HMS-Format und versuchst den Integer entsprechend in das Record zu casten, was mit Packed Record gehen sollte, oder du lässt dir die Zeiten vom Mediaplayer in Millisekunden angeben (Timeformat entsprechend umstellen) und rechnest selber um. :roll:

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

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: So 03.08.08 10:10 
Weder
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
type
  HMSRec = packed record
  Hours: byte;
  Minutes: byte;
  Seconds: byte;
  NotUsed: byte;
   end;

{...}

procedure TForm1.Timer12Timer(Sender: TObject);
var
TheLength: LongInt;  ThePos2:LOngint;
begin

 If Mediaplayer1.Mode = mpplaying then
 begin


MediaPlayer1.TimeFormat := tfHMS;

TheLength := Mediaplayer1.Length;
with HMSRec(TheLength) do 
begin
Label21.Caption := IntToStr(minutes); 
Label22.Caption := IntToStr(Seconds); 
end;
  
 ThePos2 := Videoplayer1.Position;
with HMSRec(ThePos2) do
begin

Label24.Caption := IntToStr(minutes); 
Label26.Caption := IntToStr(Seconds); 
end;
  end;
   end;

noch
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
type
  HMSRec = record
  Hours: byte;
  Minutes: byte;
  Seconds: byte;
  NotUsed: byte;
   end;

{...}

procedure TForm1.Timer12Timer(Sender: TObject);
var
TheLength: LongInt;  ThePos2:LOngint;
begin

 If Mediaplayer1.Mode = mpplaying then
 begin


Mediaplayer1.TimeFormat := tfmilliseconds;

TheLength := Mediaplayer1.Length;
with HMSRec(TheLength) do 
begin

Label21.Caption := IntToStr(thelength div 60000); 
Label22.Caption := IntToStr(thelength mod 60000); 
end;
   
 ThePos2 := Mediaplayer1.Position;
with HMSRec(ThePos2) do
begin
 
Label24.Caption := IntToStr(thepos2 div 60000); 
Label26.Caption := IntToStr(thepos2 mod 60000); 
end;
  end;
 end;

Futz. Was mach ich falsch?

_________________
Im Zweifelsfall immer das Richtige tun
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 03.08.08 10:18 
Hm, dann weiß ich auch nicht weiter. Könnte dann wirklich daran liegen, dass der Mediaplayer mit den Dateien nicht klar kommt. Geht das bei allen Dateien schief, oder nur bei einigen? Evtl. läuft da was bei Dateien mit variabler Bitrate falsch.

Nebenbei könnte die Fehlerbeschreibung etwas genauer sein :nixweiss:

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

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: So 03.08.08 10:28 
Es geht immer schief bei allen Liedern. Nährere Fehlerbeschreibung geht nicht weil es keine Fehlermeldung gibt. Und wenn man ein Lied abspielt kommen zahlen wie 34527 oder 2(min)und 234(sec). Ich weiß wirklich nicht warum es nicht futzt.

P.S. mein 100 Beitrag :party: :dance: :dance2: :dunce:

_________________
Im Zweifelsfall immer das Richtige tun
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 03.08.08 10:36 
Ach, ich weiß auch nicht. Das mit den Sekunden ist klar ... das muss natürlich (thepos2 mod 60000) Div 1000 oder so heißen, aber sonst :nixweiss:. Nimm halt was vernünftiges zum Abspielen. :tongue:

_________________
We are, we were and will not be.