Audiokinetic Wwise Knowledge Base

How can I be notified when an event has finished playing?

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.
}




Article Details

Last Updated
22nd o February, 2010

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?



Thank you for rating this answer.

Related Articles

No related articles were found.

Attachments

No attachments were found.

Continue