0
0

Hi

I have one more issue to this forum.I like to play two mp3 files one after other, once I tried that I got both the files playing at the same time.

Is it something wrong with my coding?

If I play two files sequentially what will be the time lag between the two files?

Thanx to the forum :)

  • You must to post comments
0
0

I play MP3’s sequentially. To do that, I constantly (once every 2 seconds) check to see if the current time is greater or equal to the end time of the file. If it is, I stop all the old one, and start the new one. This creates up to a two-second delay between songs, which I don’t much care about.

I would guess the best way is to set up a callback function. This is a function you create that FMOD calls at the end of a song. You can then start the next one with virtually no delay. It looked a bit complicated, so I didn’t bother.

—Mike

  • You must to post comments
0
0

[quote="MBro":9w9s6n9f]I would guess the best way is to set up a callback function. This is a function you create that FMOD calls at the end of a song. You can then start the next one with virtually no delay. It looked a bit complicated, so I didn’t bother.[/quote:9w9s6n9f]

It’s not that hard at all, at least with VC++…:

signed char endcallback (FSOUND_STREAM * stream, void * buf, int len, int param)
{
// Little trick to access all object members with just one paramter…
// The called method has to be public of course…

YourClass object = (YourClass)param;

object->Play();

return 0;
}

YourClass::Play( … )
{
FOUND_STREAM *stream = FSOUND_Stream_Open( “file.mp3”, mode, 0, 0 );

FSOUND_Stream_SetEndCallback(stream,endcallback,(int)this);
}

There’s a small gap (I think about 0.1-0.2s) between the tracks, because the new file has to be opened, scanned, buffered, …

  • You must to post comments
0
0

I tried the callback, and it works. However, I now get a little crackling between songs. I am stopping the existing stream, opening a new one, then playing it. It doesn’t matter whether I play WAVs or MP3s.

—Mike

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.