Sound effect not playing in loop

Sound effect not playing in loop
0.0 0

#1

Hey im porting my game from windows to android and im using the cocos2d-x-2.1.5 version for android. Im having this problem that my sound effect which plays in a loop in windows isnt playing at all on android.
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(“running.wav”, true);
However it plays fine when i just do
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(“running.wav”);
how do i fix this i want it to run in an infinite loop but not as my background music


#2

Turns out WAV files are poorly supported in Android.

I would suggest you convert to MP3, or OGG for SFX.


#3

thanks ok i will


#4

i converted it to mp3 its still not working :confused:


#5

is there any other way to make it loop?


#6

Muhammad Saad wrote:

i converted it to mp3 its still not working :confused:

but now it does play on Android? just not looping? Details!


#7

its still the same problem. when i use
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(“running.mp3”, true);
it doesnt play at all. When i do
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(“running.mp3”);
then it plays fine but just once
i even tried .ogg


#8

Just out of curiosity, what Android device are you testing on?

I have a list of device-specific SoundPool bugs that I can check.


#9

im testing on htc desire hd and samsung galaxy tab 2. same problem on both


#10

I also have the same problem .
HTC G17
mp3 , wav , ogg playEffect playMusic All do not work on android
on windows mp3 wav work fine ,ogg do not work


#11

Android 4.3 can’t loop sounds. Are you running Android 4.3?


#12

Cory Trese wrote:

Android 4.3 can’t loop sounds. Are you running Android 4.3?

Did you mean it is a bug of Android 4.3?


#13

I use HTC G17 and the cocosdenshion test sample of the TestCPP, the wav , ogg playEffect can work on this phone which system version is 4.0.3,and ogg can’t work in windows.


#14

Here is the Android 4.3 report of SoundPool being unable to loop sounds:

https://code.google.com/p/android/issues/detail?id=58113

OGG doesn’t work on windows, agreed:

http://www.cocos2d-x.org/wiki/Audio_formats_supported_by_CocosDenshion_on_different_platforms


#15

@Cory Trese
Thanks for your link. It is a bad news.


#16

so now what? no way to solve this at all?


#17

So the only workaround would be to patch SimpleAudioEngineOpenSL.cpp to detect 4.3 and then have a timed/interrupt routine that checked for the “looped” sample ending (use “s_pOpenSL->getEffectState(id)” maybe) and play it again to simulate the loop?

Wouldn’t be perfect with the odd crackle and microsecond gap between plays, but what else?


#18

To be honest, Android doesn’t support OpenSL well. So i don’t think it is a good way.
How about support playing more than one background music, then can use playBackgroundMusic on Android 4.3, or use media player instead of sound pool on Android 4.3?


#19

#2913 is created for it.
Any body knows the market share of Android 4.3?


#20

#2913 is created for it.
Any body knows the market share of Android 4.3?