0
0

I’m using FMOD for an MP3 Player I’m working on in Delphi and I’ve come across a small problem. Whenever I play an MP3 loaded in a Stream it starts again. I tried several things, but none of them worked, so can any of you help me out here?

Also, I was searching through the forum to search for an answer to this question. While searching, I found some things about Callback. That would come pretty handy in my program, but I’m not very experienced with Delphi yet, so if anyone can explain me how to work with that I’d appreciade it.

  • You must to post comments
0
0

A callback is a function that is implemented in your application. You pass the address of the function to FMOD and then when a certain event occurs, FMOD will call your function.

The parameters and return types of the callback functions are declared at the top of fmod.pas. All you have to do is decalre a function with the appropriate parameters and return type. For example, if I wanted to implement a stream callback, I need to implement the function in my code.
[code:3kizknkp]
function MyStreamCallback(Stream: PFSoundStream; Buff: Pointer; Length, Param: Integer): ByteBool; cdecl;
begin
{ My code }
end;
[/code:3kizknkp]
Now I need to register this callback with FMOD.
[code:3kizknkp]
FSOUND_Stream_SetEndCallback(MyStream, MyStreamCallback, 0); [/code:3kizknkp]
Now when the stream ends, the function MyStreamCallback will be called by FMOD.

  • You must to post comments
0
0

Thanks for explaining.

I allready tried something like that, but didn’t work. This doesn’t work either:(

I use this function:

function TMain.SongCallback(Stream: PFSoundStream; Buff: Pointer; Length, Param: Integer): ByteBool; cdecl;
begin
StopSong();
end;

and I set the callback with this code:

FSOUND_Stream_SetEndCallback(Stream, SongCallback, 0);

which gives me this error: “Incompatible types: regular procedure and
method”.

What am I doing wrong?

  • You must to post comments
0
0

A callback cannot be a method of an object. It must be a standard function.

  • You must to post comments
0
0

K, thx very much for your help sly.

I still got one problem: the answer on the question for which I actually created this post:
I can’t set the looping in the stream somehow. I tried

FSOUND_SetLoopMode(Channel, FSOUND_LOOP_OFF);

But that doesn’t work here. I thought maybe the callback function was the solution but, it only works when the stream gets stopped. So can anyone tell me what I have to do, to let the MP3 stop on the end?

  • You must to post comments
0
0

Thx, I found the problem:)

lol, stupid me, I copied part of the example code, not knowing that it contained the normal looping flag.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.