0
0

I have a problem with the delphi sample (Fmod tesbed for delphi, on windows).
When a song is finished, it starts again, whereas the next song would start.
The buttons next and precedent don’t work too.

I think, the code of the button next could be :

[code:2m2nu4pj]procedure TfrmMain.btnNextOrderClick(Sender: TObject);
var
Index: Integer;

begin
Index := lbxFiles.ItemIndex;

if FSongs[Index].Playing then
begin
btnStopClick(Sender);
FSongs[Index].Channel := FSOUND_Stream_Play(FSOUND_FREE, FSongs[Index + 1].Stream);
FSongs[Index].Playing := FSongs[Index + 1].Channel >= 0;
end;

end;[/code:2m2nu4pj]

But a condition will have to be added : when I listen to the last song and I click on next,
I wish it starts the first song of the list.

Can u say me how to do this, and when a song is finished how to start the next song ?

  • You must to post comments
0
0

Do you mean something like this??

[code:iynjpctf]
index := listbox1.itemindex;

if listbox1.itemindex < listbox1.count then
begin
btnStopClick(Sender);
FSongs[Index].Channel := FSOUND_Stream_Play(FSOUND_FREE, FSongs[Index + 1].Stream);
FSongs[Index].Playing := FSongs[Index + 1].Channel >= 0;
end
else
begin
btnStopClick(Sender);
FSongs[0].Channel := FSOUND_Stream_Play(FSOUND_FREE, FSongs[0].Stream);
FSongs[0]Playing := FSongs[0].Channel >= 0;
end;[/code:iynjpctf]

  • You must to post comments
0
0

Yes, I have done something like this.
But the function FMUSIC_IsFinished() doesn’t work.

I use it in a timer to change the song when it is finished, but the song is looping.
My code is simple :
[code:pgvhxpfr]var
Index: Integer;
begin
Index := lbxFiles.ItemIndex;
if FSongs[Index].Playing then
if FMUSIC_IsFinished(FSongs[Index].Module) then
btnNextOrderClick(Sender);
end;[/code:pgvhxpfr]

  • You must to post comments
0
0

[quote="Stilgar":689w1l6j]Yes, I have done something like this.
But the function FMUSIC_IsFinished() doesn’t work.

I use it in a timer to change the song when it is finished, but the song is looping.
My code is simple :
[code:689w1l6j]var
Index: Integer;
begin
Index := lbxFiles.ItemIndex;
if FSongs[Index].Playing then
if FMUSIC_IsFinished(FSongs[Index].Module) then
btnNextOrderClick(Sender);
end;[/code:689w1l6j][/quote:689w1l6j]

FMUSIC_IsFinished is for modules
You should use a Endcallback or FSOUND_IsPlaying if you want to know if a stream is finished.

  • You must to post comments
0
0

Sorry. There was a problem. The streams were loaded with FSOUND_LOOP_NORMAL, hence they always looped. Therefore the stream end callback would never get called and FSOUND_IsPlaying would always return true.

I have modified main.pas so that it fixes this problem. It opens the streams in non-looping mode and implements a stream end callback to advance to the next stream. Get the modified file [url=http://turbo.gamedev.net/main_with_stream_end_callback.zip:2uyrcp19]here[/url:2uyrcp19] (4KB). Just drop it into the samplesdelphi\FMod folder and recompile.

Brett, it would good for you to get that file and place it into your official repository for any possible future releases.

  • You must to post comments
0
0

Thank u Sly 😀

  • You must to post comments
0
0

haha,it’s very strang.From the condition “if FMUSIC_IsFinished(FSongs[Index].Module) and chkPlaylist.Checked then” we know the chkplaylist must be true and the Fmusic_IsFinished must be true,the program can execute the function:NextSong.But when the app run,although the chkplaylist’s value is not true ,the program also executes the function:NextSong.Why?

  • You must to post comments
0
0

Maybe there is still something to fix there.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.