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

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: Mo 13.04.09 12:11 
Hallo Delphianer :D ,
wie auf diesem Link beschrieben lese ich die Infos einer Mp3 datei aus, also Künstler, Titel etc. Nun möchte ich wenn ich auf einen Button Drücke das die beiden infos in einem Listview angezeigt werden. Ich dachte mir das inetwas so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure Button1.click;
var aAudiofile: TAudiofile; i: integer; ListItem: TListItem;

const
  Info: array[0..0, 0..1] of string = (
    (aAudiofile.Artist, aAudiofile.title)  
    ); 
begin

aAudioFile := TAudioFile.create;
  aAudioFile.GetAudioData(mediaplayer1.filename);

 for I := Low(info) to High(info) do
    begin
      ListItem := listview1.Items.Add;
      ListItem.Caption := info[I][0];
      ListItem.SubItems.add(info[I][1]);
end;
end;

Aber irgend was ist falsch :nixweiss: aber ich weiß nicht genau was.
Hoffe ihr wisst was ich meine
mfg Apollo

_________________
Im Zweifelsfall immer das Richtige tun


Zuletzt bearbeitet von Apollo am Mo 13.04.09 12:45, insgesamt 3-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 13.04.09 12:21 
Moin!

Was ist denn nicht OK? :gruebel: Der Code sieht auf den ersten Blick gut aus. :nixweiss:

_________________
There are 10 types of people - those who understand binary and those who don´t.
Apollo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: Mo 13.04.09 12:44 
Hinter:
ausblenden Delphi-Quelltext
1:
(aAudiofile.Artist,					

setzt Delphi den Cursor und schreibt "E2026 Konstantenausdruck erwartet".
Und hinter:
ausblenden Delphi-Quelltext
1:
aAudiofile.title)					

der gleiche Fehler.

_________________
Im Zweifelsfall immer das Richtige tun
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 13.04.09 12:51 
Wie willst du auch in ein konstantes Array einen Wert aus einer Variablen bekommen? Konstanten werden vor dem Ausführen des Programms festgelegt, aAudiofile ist aber eine Variable...

Und wozu das überhaupt? In dem Beitrag ist doch ein korrektes Beispiel angegeben... :roll:

// EDIT:
Machs halt genauso:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TFormX.Button1Click(Sender: TObject);
var
  aAudiofile: TAudiofile;
  ListItem: TListItem;
begin
  aAudioFile := TAudioFile.Create;
  aAudioFile.GetAudioData(MediaPlayer1.filename);
  ListItem := ListView1.Items.Add;
  ListItem.Caption := aAudiofile.Artist;
  ListItem.SubItems.add(aAudiofile.Title);
  aAudioFile.Free;
end;
// EDIT2:
Das Free hattest du auch weggelassen, das ist natürlich sehr ungünstig. Wozu meinst du ist so ein Beispiel denn da, wenn du es dann ganz anders machst? :lol:
Apollo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Windows 7
Delphi 3 Prof., Delphi 2005
BeitragVerfasst: Mo 13.04.09 12:57 
Super, vielen vielen Danke :D :D :D
Es läuft :wink:

_________________
Im Zweifelsfall immer das Richtige tun