I'm trying to load a sound with irrKlang library and it works fine at playing, but I want to get PlayLength() and PlayPosition() properties but program crashes when done. This is what I do:
#define ResX "res.mod"
irrklang::ISoundEngine* se = irrklang::createIrrKlangDevice();
if( !se->isCurrentlyPlaying( ResX ) ){
irrklang::ISound *s = se->play2D( ResX, false, false, false );
while( s->getPlayPosition() < s->getPlayLength() ) //Do something
}
When I do s->getPlayPosition() or s->getPlayLength() program crashes
I put some clarificaction here first:
I cant use while( se->isCurrentlyPlaying( ResX ) ) because isCurrentlyPlaying() doesn't return 0 when media stopped playing sometimes.
You aren't checking the return value of play2D to see if it is a valid pointer or not (and it isn't)
Your code says:
According to the docs:
So, you pass false for 'track', 'startPaused' and 'enableSoundEffects' and the docs specifically say that a valid pointer will not be returned unless one of them is true.