Music and Sounds With Your Cordova/Phonegap Application

Cordova Music Plugin for Apache CordovaMusic and sound effects on your Apache Cordova / Phonegap mobile application is not seem to be a headpain. The recommended plugin works great for me with both iOS and Android.

With Native Audio plugin you can integrate this feature to your project in a few minutes. I’ll show you how. Also I’ll provide you an example of AngularJS service to control audio effects in your app.

  • Install native audio plugin

  • All sounds you’re planning to use in your app must be preloaded before use. Plugin provides two functions to do this. The first function can be used to preload short sound (for example sound effect for button click)

The second function is optimized for long sounds loading (such as background music)

Both functions are available via window.plugins.NativeAudio.preloadXXXX. id is unique sound identifier which will be used to control sound playback.

  • Playback control is really simple with Cordove Native Audio plugin:

You need to pass the same id as you passed to preloadXXX functions.

  • For AngularJS/Ionic framework applications you can use a service like this:

One thought on “Music and Sounds With Your Cordova/Phonegap Application”

Leave a Reply

Your email address will not be published. Required fields are marked *