0
0

I want to interrupt a song in the moment when 10 seconds of the song have been played… but I don’t know how to achieve that.
My code is as follows

[code:1l5x7lgk]

include <fmod.h>

include <fmod_errors.h>

FMUSIC_MODULE *mod = NULL;

// init
if (!FSOUND_Init(44100, 64, 0))
{
printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
exit(1);
}

// load song
mod = FMUSIC_LoadSong(&quot;invtro94.s3m&quot;);

if (!mod)
{
    printf(&quot;%s\n&quot;, FMOD_ErrorString(FSOUND_GetError()));
    exit(1);
}
//

FMUSIC_PlaySong(mod);

if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
printf("Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}

do
{
if (FMUSIC_GetTime(mod)==10000)
{
FMUSIC_FreeSong(mod);
FSOUND_Close();
}
}
while (FMUSIC_IsPlaying(mod);
[/code:1l5x7lgk]

What am I doing wrong in here? Please, help me. Should I use another funcion? Do I need to create a different conditional?

  • You must to post comments
0
0

it may be because you are looking for the time to be exactly 10s, if you look for it being more than 10s instead it may work

  • You must to post comments
0
0

[quote="birty":34t320s3]it may be because you are looking for the time to be exactly 10s, if you look for it being more than 10s instead it may work[/quote:34t320s3]

What? Is this a limitation of FMOD or you’re mocking me?
😮

BTW: No matter the seconds or ms, it does not work

  • You must to post comments
0
0

no its because FMUSIC_GetTime wont be called every millisecond so it is very unlikely to ever be exactly 10000, also fmod may not update this value every ms. try changing your code to
[code:32gelsa3]if (FMUSIC_GetTime(mod)>10000)
{
FMUSIC_FreeSong(mod);
FSOUND_Close();
} [/code:32gelsa3]

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.