0
0

So i was trying to play one sound after another but the way my code did was play both at the same time, is there a way to check when a sound/song is finished then act accordingly to it? like "if sound->finished() do kill enemy" or something i’ve looked through the API docs haven’t been able to find anything.

  • You must to post comments
0
0

Have a look at Channel::isPlaying(). Or, if you’re using the Event system, the proper query is Event::getState() and look for the FMOD_EVENT_STATE_PLAYING flag.

  • You must to post comments
0
0

sorry for the LATE LATE replay but been busy. I tried the "isplaying" route but for some reason it’s not working right. take this por example:

[code:2nbt74am]

ISound2D* lemons_one = new ISound2D();
lemons_one->createSound("Lemons_one","Content\Sounds\game\SoundTrial\Lemons_one.wav",true);

lemons_one->Play();

if (lemons_one->isPlaying())
{
    m_pFont->setText("sound is playing");
}
else 
{
    m_pFont->setText("soud is not playing");
}

[/code:2nbt74am]

seems harmless enough right? well, when ran, after the sound is done, the first text is stll displayed.

now here’s how im calling the is playing function:

[code:2nbt74am]

    bool isPlaying()
    {
        bool bIsPlaying;
        FMOD_RESULT fRes = m_pChannel->isPlaying(&bIsPlaying);

        IAudioManager::getSingletonPtr()->AudioError(fRes);

        return bIsPlaying;
    }

[/code:2nbt74am]

of course, that’s not working, so idk. Hmm, maybe i did something wrong?

  • You must to post comments
0
0

It is possible for the channel to expire and that would cause an FMOD_RESULT such as FMOD_ERR_INVALID_HANDLE to be returned. What does your AudioError function do, is it catching any errors? Generally the best way to check if a channel is playing is to do something like this:
[code:10kc89md]
bool isPlaying()
{
bool bIsPlaying = false;
FMOD_RESULT fRes = m_pChannel->isPlaying(&bIsPlaying);
if (fRes == FMOD_ERR_INVALID_HANDLE || fRes == FMOD_ERR_CHANNEL_STOLEN)
{
return false; // Expected error
}

     IAudioManager::getSingletonPtr()->AudioError(fRes);

     return bIsPlaying;
  }

[/code:10kc89md]

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.