Software Archive
Read-only legacy content

an issue of playing multiple audios in cordova media plugin

Bigfanx__
Beginner
864 Views

Sorry guys, I am back to the troublesome cordova media plugin again! Now I got a new problem of playing multiple sounds using the media plugin in intel xdk. I have a background music loop playing in the app. I also have another sound of some kind for object moving in the app. However, the two sounds interfere with each other when they are playing at the same time. I mean the sound for object moving played initially when the background music was loop playing at the same time, but it then stopped after a while and no more play while the background music is still on. It seems it is a bug in cordova media plugin. Is there any walkaround to overcome the problem? I googled a lot and only got a negative response from the internet. Thanks a lot for any help.

0 Kudos
3 Replies
Amrita_C_Intel
Employee
864 Views

Hello,

Try following this link. I think it has chunks of code for game where multiple music and sounds are played. So this should be helpful.

http://www.html5rocks.com/en/tutorials/webaudio/games/

or see if you can us ethis web audio library 

http://goldfirestudios.com/blog/104/howler.js-Modern-Web-Audio-Javascript-Library

0 Kudos
Anusha_M_Intel1
Employee
864 Views

You want them to play at the same time and now they don't?

A few things to consider:

- According to their documentation, Android and iOS allow two sounds being played simultaneously. Windows and Blackberry (a few devices) do not. 

- Make sure you are not using the same media object for the second sound

- It could be a device issue. Do try it on another device to confirm. 

- A popular alternative to Cordova media plugin esp when targeting concurrency is: https://github.com/floatinghotpot/cordova-plugin-nativeaudio 

0 Kudos
Bigfanx__
Beginner
864 Views

Hi, after several hours research and testing, I found cordorva-plugin-nativeaudio from floatinghotpot can meet my requirement. It enables low latency and polyphony.  I switched to this wonderful plugin and it is working perfectly on my android phone. Thanks a lot to all for helps.

0 Kudos
Reply