Autor Beitrag
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Mi 26.03.03 21:19 
Ich lese die ID3 Tags mit diesem Code:
ausblenden volle Höhe 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:
type 
  TID3Tag = record 
    ID: string[3]; 
    Titel: string[30]; 
    Artist: string[30]; 
    Album: string[30]; 
    Year: string[4]; 
    Comment: string[30]; 
    Genre: Byte; 
  end; 

{...}

function readID3Tag(FileName: string): TID3Tag; 
var 
  FS: TFileStream; 
  Buffer: array [1..128] of Char; 
begin 
  FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); 
  try 
    FS.Seek(-128, soFromEnd); 
    FS.Read(Buffer, 128); 
    with Result do 
    begin 
      ID      := Copy(Buffer, 1, 3); 
      Titel   := Copy(Buffer, 4, 30); 
      Artist  := Copy(Buffer, 34, 30); 
      Album   := Copy(Buffer, 64, 30); 
      Year    := Copy(Buffer, 94, 4); 
      Comment := Copy(Buffer, 98, 30); 
      Genre   := Ord(Buffer[128]); 
    end; 
  finally 
    FS.Free; 
  end; 
end;


Doch wie kann ich feststellen, ob überhaupt ID3-Tags existieren? Wenn dies nämlich der Fall ist, bekomme ich als Ausgabe der Funktion nur unbrauchbare Zeichenfolgen, ist ja klar.


Moderiert von user profile icontommie-lie: Beitrag nach Multimedia verschoben

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 26.03.03 21:45 
Wenn das ID-Field "TAG" enthält, dann ist es ein ID3v1-Tag. v2-Tags kannst du mit dem ganzen Code nicht ausfindig machen, auch nicht auslesen.
Im Prinzip kannst du nach dem
ausblenden Quelltext
1:
ID := Copy(Buffer, 1, 3);					

eine if-Abfrage machen und erst bei positivem Test den Rest auch in die entsprechenden Variablen laden. Spart auf jeden Fall ein paar Taktzyklen ein.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Do 27.03.03 13:48 
Danke erstmal! Doch wie kann ich ID3v2 auslesen?

P.S.: Sorry das ich in die falsche Sparte geschrieben habe, ich muss mich irgendwie verklickt haben.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 28.03.03 18:11 
ID3v2 ist nicht-statisch, sondern framebasiert. Wesentlich komplizierter. Juergen Faul hat dafür mal eine extrem primitive Unit geschrieben, die für die Basics reichen wird: http://www.torry.net/vcl/mmedia/other/mpegplus.zip
Ich arbeite zur Zeit selbst an eine entsprechenden Klasse, die beide Versionen und noch Ogg unterstützt. Auch von der kannst du den bisherigen Quellcode haben (ID3v2-Schreiben wird noch nicht unterstützt).

edit: Link geändert.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert