For Android, you need to set permissions in addition to handling the media object with the appropriate plugin.
Permissions on Android
(in app/res/xml/config.xml)
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
(in app/AndroidManifest.xml)
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Media Object
// Audio player
//
var meu_objeto_media = new Media(src, onSuccess, onError);
src is your file path.
The other parameters are callbacks.
After instantiating your Media object run the play method:
// Play audio
meu_objeto_media.play();
Take an example here.
You have set up permission to run audio on your Android project?
– bpinhosilva
I do it in HTML itself?
– Jhonny Rubio Dos Santos
No, in your Android project when it matters the phonegap project. In the Manifest file.
– bpinhosilva