Proszę poświęćcie chwilę i pomóżcie bo już pomysłów brak :(
Problem dotyczu biblioteki BASS i plików mp3.
Program odtwarza ale przeskakuje niektóre pliki i odgrywa następny z playlisty.
Nie mogę sobie z tym poradzić bo nie ma regóły co do pliku, najpierw myślałem że tyczy się to plików ze zmiennym bitrate ale okazuje się że niekoniecznie.
Poniżej kod:
procedure TMainFrm.FormCreate(Sender: TObject);
begin
BASS_Init(1, 44100, 0, Application.Handle, nil); //inicjalizacja biblioteki BASS
DirectoryListBox1.Directory:=InputBox('Gdzie jest muzyka?', 'Podaj folder z muzyką:', '');
end;
procedure TMainFrm.btnPlayClick(Sender: TObject);
begin
if Listbox1.Items.Count>0 then
begin
Timer1.Enabled:=True;
if BASS_ChannelisActive(Channel) = BASS_ACTIVE_PLAYING then
BASS_ChannelStop(Channel); //jeżeli gra to to stop
Channel := BASS_StreamCreateFile(FALSE, PChar(ListBox1.Items.Strings[0]), 0, 0, 0); //nowy strumień
BASS_ChannelPlay(Channel, False); //play
Label2.Caption:=(ExtractFileName(ListBox1.Items.Strings[0]));
end else
begin
Timer1.Enabled:=False;
Timer2.Enabled:=True;
end;
end;
procedure TMainFrm.Timer1Timer(Sender: TObject);
begin
//jeżeli kanał jest aktywny to
//if BASS_ChannelIsActive(Channel) = BASS_ACTIVE_PLAYING then
//następna
if Trunc(BASS_ChannelBytes2Seconds(Channel, BASS_ChannelGetPosition(Channel))) = trunc(BASS_ChannelBytes2Seconds(Channel, BASS_StreamGetLength(Channel))) then
begin
ListBox1.Items.Delete(0);
btnPlay.Click;
end;
end;
procedure TMainFrm.Timer2Timer(Sender: TObject);
begin
if ListBox1.Items.Count>0 then
begin
Timer2.Enabled:=False;
btnPlay.Click;
end;
end;
procedure TMainFrm.Timer3Timer(Sender: TObject);
begin
Label3.Caption:=(IntToStr(ListBox1.Items.Count));
if BASS_ChannelIsActive(Channel) = BASS_ACTIVE_PLAYING then
lblTime.Caption := Seconds2MinsAndSecs(Trunc(BASS_ChannelBytes2Seconds(Channel, BASS_ChannelGetPosition(Channel)))) + '/' + Seconds2MinsAndSecs(Trunc(BASS_ChannelBytes2Seconds(Channel, BASS_StreamGetLength(Channel))));
end;