Autor Beitrag
Nils:D
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 131

Debian, Win XP
Delphi 7 Arch.
BeitragVerfasst: Sa 22.10.05 14:01 
Hi,

selbst wenn es hierzu schon viele Threads gibt. Ich bin weder bei Google fündig geworden und auch hier hab ich nicht das passende gefunden.

Ich arbeite an einer Playlist. Es sollen natürlich solche Items, wie z.B. 'C:\bla.mp3' nicht existieren. Anstelle von dem Filename möchte ich den Namen der Band und den Namen des Lieds dort stehen haben. Ist das irgendwie machbar.


Kurzgefasst:
- nach Auswahl und Enter im OpenDialog, wird ein Item in der Playlist mit Bandname und Liedname hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 22.10.05 14:04 
user profile iconNils:D hat folgendes geschrieben:
selbst wenn es hierzu schon viele Threads gibt. Ich bin weder bei Google fündig geworden und auch hier hab ich nicht das passende gefunden.
:gruebel: Suche in: Delphi-Library ID3*

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Nils:D Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 131

Debian, Win XP
Delphi 7 Arch.
BeitragVerfasst: Sa 22.10.05 14:11 
user profile iconChristian S. hat folgendes geschrieben:
user profile iconNils:D hat folgendes geschrieben:
selbst wenn es hierzu schon viele Threads gibt. Ich bin weder bei Google fündig geworden und auch hier hab ich nicht das passende gefunden.
:gruebel: Suche in: Delphi-Library ID3*

Tja. Das läuft nicht. Es tritt bei dem Beitrag von Gausi (bei der 'eiegntlichen Prozedur') hier der Fehler: Inkompatible Typen 'Byte' und 'TMPEGHeader' bei
ausblenden Delphi-Quelltext
1:
neueframelength := GetFramelength(mp3_header);					

auf.
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: Sa 22.10.05 14:42 
Die Funktion GetFramelength gibt es zweimal (mit verschiedenen Parametern), daher muss man die im Kopf der Unit mit overload kennzeichnen, dann sollte es laufen.

Es wird Zeit, dass ich mal ne Unit "Mp3Utils" hier reinstelle...die ist aber noch nicht ganz fertig. Dann inklusive Beispiel-Prog. Ich hoffe, die läuft dann besser als diese Unit da, die mir (bzw. anderen ;-) )schon jede Menge Ärger gemacht hat...

_________________
We are, we were and will not be.
Nils:D Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 131

Debian, Win XP
Delphi 7 Arch.
BeitragVerfasst: So 23.10.05 11:09 
Ich habe eine Lösung gefunden.

Es werden
6 Edits (edTitle, edArtist, edAlbum, edYear, edGenre, edComment)
1 ListBox (Playlist)
1 StaticText (txtFolder)
gebraucht
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:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
type
  TID3Rec = packed record
    Tag     : array[0..2] of Char;
    Title,
    Artist,
    Comment,
    Album   : array[0..29] of Char;
    Year    : array[0..3] of Char;
    Genre   : Byte;
  end;

const
  MaxID3Genre=147;
  ID3Genre: array[0..MaxID3Genre] of string = (
    'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge',
    'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B',
    'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska',
    'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient',
    'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical',
    'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel',
    'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative',
    'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic',
    'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk',
    'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult', 'Gangsta',
    'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American',
    'Cabaret', 'New Wave', 'Psychadelic', 'Rave', 'Showtunes', 'Trailer',
    'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz', 'Polka', 'Retro',
    'Musical', 'Rock & Roll', 'Hard Rock', 'Folk', 'Folk-Rock',
    'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin', 'Revival',
    'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock',
    'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band',
    'Chorus', 'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson',
    'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus',
    'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba',
    'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle',
    'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall',
    'Goa', 'Drum & Bass', 'Club-House', 'Hardcore', 'Terror', 'Indie',
    'BritPop', 'Negerpunk', 'Polsk Punk', 'Beat', 'Christian Gangsta Rap',
    'Heavy Metal', 'Black Metal', 'Crossover', 'Contemporary Christian',
    'Christian Rock', 'Merengue', 'Salsa', 'Trash Metal', 'Anime', 'Jpop',
    'Synthpop'  {and probably more to come}
  );

implementation

{$R *.dfm}

uses ShellAPI, ShlObj;

procedure TForm1.FillID3TagInformation(mp3File:string; Title,Artist,Album,Year,Genre,Comment:TEdit);
var //fMP3: file of Byte;
    ID3 : TID3Rec;
    fmp3: TFileStream;
begin
  fmp3:=TFileStream.Create(mp3File, fmOpenRead);
  try
    fmp3.position:=fmp3.size-128;
    fmp3.Read(ID3,SizeOf(ID3));
  finally
    fmp3.free;
  end;

 { or the non Stream approach - as in ChangeID3Tag procedure
 try
   AssignFile(fMP3, mp3File);
   Reset(fMP3);
   try
     Seek(fMP3, FileSize(fMP3) - 128);
     BlockRead(fMP3, ID3, SizeOf(ID3));
   finally
   end;
 finally
   CloseFile(fMP3);
 end;
 }

 if ID3.Tag <> 'TAG' then begin
   Title.Text:='Wrong or no ID3 tag information';
   Artist.Text:='Wrong or no ID3 tag information';
   Album.Text:='Wrong or no ID3 tag information';
   Year.Text:='Wrong or no ID3 tag information';
   Genre.Text:='Wrong or no ID3 tag information';
   Comment.Text:='Wrong or no ID3 tag information';
 end else begin
   Title.Text:=ID3.Title;
   Artist.Text:=ID3.Artist;
   Album.Text:=ID3.Album;
   Year.Text:=ID3.Year;
   if ID3.Genre in [0..MaxID3Genre] then
     Genre.Text:=ID3Genre[ID3.Genre]
   else
     Genre.Text:=IntToStr(ID3.Genre);
   Comment.Text:=ID3.Comment
 end;
end;

procedure TForm1.FillMP3FileList(Folder: string; sl: TStrings);
var Rec : TSearchRec;
begin
 sl.Clear;
 if SysUtils.FindFirst(Folder + '*.mp3', faAnyFile, Rec) = 0 then
  try
    repeat
      sl.Add(Rec.Name);
    until SysUtils.FindNext(Rec) <> 0;
  finally
    SysUtils.FindClose(Rec);
  end;
end;

function TForm1.BrowseDialog(const Title: string; const Flag: integer): string;
var
  lpItemID : PItemIDList;
  BrowseInfo : TBrowseInfo;
  DisplayName : array[0..MAX_PATH] of char;
  TempPath : array[0..MAX_PATH] of char;
begin
  Result:='';
  FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
  with BrowseInfo do begin
    hwndOwner := Application.Handle;
    pszDisplayName := @DisplayName;
    lpszTitle := PChar(Title);
    ulFlags := Flag;
  end;
  lpItemID := SHBrowseForFolder(BrowseInfo);
  if lpItemId <> nil then begin
    SHGetPathFromIDList(lpItemID, TempPath);
    Result := IncludeTrailingBackslash(TempPath);
    GlobalFreePtr(lpItemID);
  end;
end;

Aufgerufen wird es dann so:
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:
// per Klick auf eine in der ListBox angezeigten Datei werden die Informationen
// in den 6 Edits angezeigt
procedure TForm1.playlistClick(Sender: TObject);
var mp3File:string;
begin
  if mp3List.Items.Count=0 then exit;
  mp3File := Concat(txtFolder.Caption, mp3List.Items.Strings[mp3List.ItemIndex]);
  if not FileExists(mp3File) then begin
   ShowMessage('MP3 file '+#13#10+ mp3File +#13#10+'does not exist!');
   exit;
  end;

  FillID3TagInformation(mp3File, edTitle, edArtist, edAlbum, edYear, edGenre, edComment);
end;

// per DblClick wird das ausgewählte Lie abgespielt.
procedure TForm1.playlistDblClick(Sender: TObject);
var mp3File:string;
begin
  if mp3List.Items.Count=0 then exit;
  mp3File := Concat(txtFolder.Caption, mp3List.Items.Strings[mp3List.ItemIndex]);
  BassDllPlayer1.play(mp3file); // hier wird es abgespielt, es kann natürlich durch   //andere Audio-Engines ausgetauscht werden
end;
Nils:D Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 131

Debian, Win XP
Delphi 7 Arch.
BeitragVerfasst: Di 25.10.05 14:10 
Damit wäre zwar das Problem mit der playlist gelöst. Aber ich möchte allgemein den Dateinamen, also das Verzeichniss etc. in einem Label stehen haben, kein Problem. Aber daneben sollte dann noch der Titel und der Artist stehen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var mp3file: string;
begin
  Label7.Caption := op1.FileName;
  bassdllplayer1.Play(Label7.Caption);
  Label5.Caption := IntToStr(bassdllplayer1.Length);
  tb1.MaxValue := bassdllplayer1.Length;
  tb1.Position := 0;
  ocillo := True;
  ocillotimer.Enabled := True;
  mp3File := Concat(Label7.Caption);
  FillID3TagInformation(mp3file, pform.edTitle, ed, pform.edAlbum, pform.edYear,    pform.edGenre, pform.edComment);

Da kann delphi die Datei nicht finden. In Label7 steht der Filename. Der restliche Code steht einen Beitrag drüber.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 07.07.06 15:59 
der code funzt aber nur für v1 tags!!! oder?

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
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: Fr 07.07.06 16:09 
Schau mal hier. Das ist eine Weiterentwicklung von meinem Beitrag, der weiter oben mal angesprochen wurde. Der Code ist dann auch für ID3v2 in allen Subversionen (v2.2 bis v2.4) - lesend und schreibend.

_________________
We are, we were and will not be.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 07.07.06 16:16 
Ja,ja!!! den beitrag hab ich gesucht!!! danke danke danke!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

mfg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.