Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue on Android Devices while looping sounds using playBackgroundMusic Method in Cocos2d-x CocosDenshion

I am using the playBackgroundMusic() method to play my music files.
I have set the loop parameter to true.
I have tried the following formats:

  • .wav
  • .ogg
  • .mp3
  • .mp4
  • .m4a

The problem is that the file is looping, but it is not looping seamlessly on android devices.
It loops perfectly well on iphone anf ipad.

Every-time the file end is reached, there is a small gap and then it plays again.
The gap is about a fraction of a second, but still noticeable.

I have tried 5-6 different sounds and also changed the formats. No Luck!!

I have also build the "Tests" project that comes with the cocos2d-x library, on my android device and played the CocosDenshion Test.
It seems that even that one is having a problem with seamless looping.

Has anyone tried this??
I would really appreciate if any one pitches in with their idea. :)

If I use playEffect(), then the sound loops, but I do not want to use playEffect for playing music files.

NOTE :- I am using cocos2d-x 1.0.1-x-0.11.0 version.
Which is the latest.

like image 502
virtualamod Avatar asked Nov 13 '22 09:11

virtualamod


1 Answers

I am new in stackoverflow. I am using cocos2d-x 3.1 and following code is working perfectly fine:

CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("music.ogg", true);

Try to port your code to newer version of cocos2d-x. I hope it helps

like image 67
mohakagr Avatar answered Nov 16 '22 02:11

mohakagr