When posting an event (using PostEvent()), you may register a callback that will be called when the event has finished playing.
For example, if you have a situation where you have a sound A that must be played, and while A is playing,
B must be paused (not muted), you could use the following sample code:
const AkTChar Play_A[] = L"Play_A";
const AkTChar Play_B[] = L"Play_B";
const AkTChar Pause_B[] = L"Pause_B";
const AkTChar Resume_B[] = L"Resume_B";
AkGameObjectID mygameObject_ID = 666;// dummy game object for this sample code.
void MyCallbackReaction( AkCallbackType in_eType, AkCallbackInfo* in_pCallbackInfo )
{
if( in_eType == AK_EndOfEvent && in_pCallbackInfo->pCookie )
{
// In this sample I used the input game object ID, but it could be a different one.
// You could have put the game object ID somewhere in the cookie too.
AK::SoundEngine::PostEvent(
(AkLpCtstr)in_pCallbackInfo->pCookie,
in_pCallbackInfo->gameObjID );
}
}
void SomeGameThreadFunction()
{
AK::SoundEngine::PostEvent( Play_B, mygameObject_ID );
//(snip...) B is playing
// Now time to pause B, play A, and request to resume B after A is finished
AK::SoundEngine::PostEvent( Pause_B, mygameObject_ID );
AK::SoundEngine::PostEvent(
Play_A,
mygameObject_ID,
AK_EndOfEvent,
MyCallbackReaction,
(void*)Resume_B /*use the event name as cookie for example*/
);
//(snip...)
// B will resume once A is finished.
}