I’m a newbie, and I don’t know how to set up this callback. I have search for the samples, but there’s any setendcallback. I have read another topic where it says how to set up it, but it’s no clear… Can you help me on it?
Reading the help, it is no clear if this callback is called when I force a FSOUND_stream_Stop, or when the song finish playing, then is called. I mean that what i want is a callback that is fired when my song file finishes playing (reach the end of the song). Is this the appropiate callback?
- petranca asked 13 years ago
Besides, with Play(..) the song is played from the beginning and immediacly after this you skip the position. I’d recommend PlayEx with pause flag, SetPosition, and SetPaused when starting a song from a certain position, else there could be stutter on slow devices.
As for the callback functions: You can use static member functions, too.
I’d recommend to offer a pointer to the object as callback parameter, then cast it back to the object pointer and call some object method.
- Mort answered 13 years ago
Hi…The End callback works the way you want, I think … When a stream stops playing, this callback is called… it can be when a stream reaches the end…
When you load the stream, you can set this end callback using
FSOUND_Stream_SetEndCallback(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback,int userdata)…
then in the callback you can make the things you want when a stream reaches the end…
signed char F_CALLBACKAPI callback_name(FSOUND_STREAM *stream,void *buff,int len,int param);
thank you very much for your answer, but I get this error when compiling:
error C2664: ‘FSOUND_Stream_SetEndCallback’ : cannot convert parameter 2 from ‘signed char (struct FSOUND_STREAM *,void *,int,int)’ to ‘signed char (__cdecl *)(struct FSOUND_STREAM *,void *,int,int)’
what is (__cdecl *)???
in the .h file I have:
signed char F_CALLBACKAPI CallbackMP3_2(FSOUND_STREAM *mp32,void *buff,int len, int param);
and in the ini function of my .cpp file I have:
and the callback in the same *cpp:
signed char F_CALLBACKAPI CMP3::CallbackMP3_2(FSOUND_STREAM *mp32,void *buff,int len, int param)
please would you help me?? what am I doing wrong???
I had the same error… i think this error occurs when you are using classes… I upgraded to version 3.70, and I did this (it worked for me):
in the .h file: (cCLASS.h)
static signed char __stdcall Callback(FSOUND_STREAM *stream,void *buff,int len,int param);
signed char __stdcall Callback_Function(FSOUND_STREAM *stream,void *buff,int len,int param);
in .cpp file: (cCLASS.cpp)
//setting the end callback
//the static function, that will set the callback…then you can
//use the atributes of the class inside the callback
signed char __stdcall cCLASS:Callback(FSOUND_STREAM stream,void *buff,int len,int param)
return ((cCLASS)param)->Callback_Function(stream, buff, len, param);
//and, finally, the callback function…
signed char __stdcall cCLASS::Callback_Function(FSOUND_STREAM *stream,void *buff,int len,int param)
//put the code of the callback here
I think it works ….
Oh my god, it really works! that’s amazing. 😀
But now it takes me to ask another question: how was I supposed to guess all that initialitzations to set up this callback?????
I took a look to the help file, but i didn’t find anythig explaninig how to set it up, and, if i’m not wrong, there’s no sample with a callback set up. Or it is?
well, thank you very much for your help, and I propose to add this piece of topic to the help file or something like this.
hi brett, i’m not an advanced c++ programmer, and that’s why I needed to ask in this forum. I had never seted up a callback before. What I’m only saying is that in the help file that comes with the api, there’s no example (I say example, not the prototype function). Usually, the VC++ documentation comes with examples and it’s very helpfully.
Maybe I didn’t see an exemple (if it is really in the help), but if there’s no one, I propose you to add it to the next release.
I fought now half of the day with callbacks and can’t figure it out myself.
I want my background music to loop between the end and a point other then the beginning (after it at first played entirely from start to end).
So, I set up an endCallback function which processes:
[code:3ua6mvla]function callback(Stream: PFSoundStream; Buff: Pointer; Length, Param: Integer): ByteBool;
All works fine, the stream is playing again after it ended, and the second time it plays from the desired position.
But the problem now is – there is a notable delay before it replays (about 500ms pause).
Any ideas where this comes from and – more important: how to overcome it?
I load the stream as follows:
[code:3ua6mvla]pTest_BgMusic := FSOUND_Stream_Open(PAnsiChar(filename),FSOUND_LOOP_OFF,0,0);
- BlackOut answered 13 years ago
Please login first to submit.