Let me save you a lot of time: The Cordova Media plugin (org.apache.cordova.media) does not work well on Android and Windows Phone 8, at least in the version released with Cordova 3.1 (and I don’t see any indication of a change in the latest release either).
On Android I assume media resources are not released by the plugin since after a few plays, the audio does not play anymore unless the application is restarted. On Windows Phone 8, the audio sort of plays, but causes the application to behave very strangely (unrelated Javascript callbacks are not invoked, probably due to threading issues and extremely sluggish behaviour in general)
What I did to play audio in a Cordova application was the following:
For Android, iPhone – use the following plugin:
cordova plugin add https://github.com/triceam/LowLatencyAudio
For Windows Phone 8, create a static HTML5 audio tag, get a pointer to it from the DOM (e.g, by getElementById) and just use the ‘play’ method on the returned object whenever you want to play the audio.
Leave a Reply