Hi,
wenn ich mehrere Lieder zu meiner Playlist hinzufüge, wird immer nur das letzte abgespielt, egal welches ich auswähle. Wie kann ich das Problem beheben.
Delphi-Quellcode:
TID3Tag = record
ID: string[3];
Titel: string[30];
Artist: string[30];
Album: string[30];
Year: string[4];
Comment: string[30];
Genre: Byte;
end;
TMusicObj = class(TObject)
private
FFilename: String;
FID3 : TID3Tag;
public
property FileName: String read FFileName write FFileName;
property ID3 : TID3Tag read FID3 write FID3;
end;
var
...
filename: String;
procedure TfrmMain.Button2Click(Sender: TObject); // Abspiel Button
begin
if playlist.ItemIndex = -1 then
exit;
BASS_MusicFree(chan);
BASS_StreamFree(chan);
frmSpectrum.Timer1.Enabled := True;
filename := TMusicObj(ObjList[playlist.ItemIndex]).FileName;
PlayFileF(filename);
end;
procedure TfrmMain.Button3Click(Sender: TObject); // Hinzufügen Button
var i: Integer;
begin
BASS_MusicFree(chan);
BASS_StreamFree(chan);
if o.Execute then
begin
MusicObj.FileName := o.FileName;
MusicObj.ID3 := ReadID3Tag(o.FileName);
ObjList.Add(MusicObj);
playlist.Items.Add(ExtractFileName(MusicObj.FileName));
end;
end;
function TfrmMain.PlayFileF (filename: string): boolean;
begin
result := false;
if checkPlayAll.Checked = False then
playlist.Items.Strings[playlist.ItemIndex + 1];
chan := BASS_StreamCreateFile(FALSE,pchar(filename),0,0,0);
if chan = 0 then
begin
chan := BASS_MusicLoad(False, pchar(filename), 0, 0, BASS_MUSIC_RAMPS or BASS_MUSIC_POSRESET or BASS_MUSIC_PRESCAN, 0);
if (chan = 0) then
begin
ErrorPop('Kann das Lied nicht abspielen !');
Exit;
end;
end;
end;