简体   繁体   中英

playing audio with SoundJS in Intel XDK

I'm playing audio in my HTML5 app using:

createjs.Sound.play('boom-sound');

I then imported the project to Intel XDK. Now the game is playing smoothly in the emulator but the no sounds are there. I also tested after building the app for android and no audio was there.

Any idea, anyone?

soundjs does not work that well, I've also had problems making it play sound on IOS devices in the past. To fix this problem I now use howler.js .

SoundJS has run into trouble in environments like Intel XKD and PhoneGap because it defaults to using the WebAudioPlugin. While Web Audio may be available, it needs to load audio through XHR which will not work with local files.

Loading files from an external server would get around this, but require the app to fetch data which is less than ideal. Using createjs.Sound.registerPlugins([HTMLAudioPlugin]) would get around this but HTML audio playback is sometimes limited on mobile devices.

Luckily, SoundJS recently added a CordovaAudioPlugin , and since Intel XDK is based on Cordova this should give you full SoundJS functionality. You'll need to grab the plugin and the latest SoundJS-NEXT from github . Then you can setup the plugin with registerPlugins

createjs.Sound.registerPlugins([CordovaAudioPlugin]);

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM