SimpleAudioEngine help

i use SimpleAudioEngine to play background music only once, and in update() to see if the background music has finished playing, here is my code:

`CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(“bg.mp3”, false); // play only once

void MyClass::update(ccTime delta) {
CCLOG(“is background music playing=%i”, CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying());
}`

but when the sound has played once, isBackgroundMusicPlaying() will continue retrun ‘true’, is there anything wrong?

thanks.

I have tested it, and there is not problem.

CCLOG->isBackgroundMusicPlaying());
The code is error.
You should paste real code.

sorry, the code i pasted is wrong, actually it is:

CCLOG (“is background music playing=%i”, CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying());

and also, i tryed CocosDenshionTest in cocos2d-x’s test and i changed ‘true’ to ‘false’

SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::fullPathFromRelativePath(MUSIC_FILE)).c_str(), false);

and when the audio play once, i click ‘isBackgroundMusicPlaying’, it also show me ‘’background music is playing’’.

thanks.

oh, i pasted

CCLOG (‘is background music playing=i’, CocosDenshion::SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying());

when i submitted, it changed…

You should click isBackgroundMusicPlaying after background music is stop.

i tried it on ipod touch just now, it worked, when the sound finished playing, it show me ‘background music is not playing’

but in simulator, it can’t run.

i don’t know why, the same codes.

I can confirm this issue. On the Simulator isBackgroundMusicPlaying returns true after the first audio file is played - forever, as if the file never stopped. On an iOS device, it works fine. I am now about to test this on Android.

@Craig McMahon, sorry I can’t reproduce the bug as you described. My env is
* xcode 4.3.3
* cocos2d-x 2.0.2
* iphone 5.1 simulator
CocosDenshionTest works as excepted.

What’s your environment to reproduce this bug?

hi i am having same problem…
i am using XCode 4.5
cocos2d-2.0-x-2.0.2
ipad 6 simulator

Walzer Wang wrote:

@Craig McMahon, sorry I can’t reproduce the bug as you described. My env is
* xcode 4.3.3
* cocos2d-x 2.0.2
* iphone 5.1 simulator
CocosDenshionTest works as excepted.
>
What’s your environment to reproduce this bug?

Hi, do you have resolved this problem?
Thanks!