getMediaURL() working fine for android application but i did't get audio path for iOS application.
function playAudio(sound) {
var mp3URL = getMediaURL(sound);
var media = new Media(mp3URL, null, mediaError);
media.setVolume(1.0);
media.play();
}
function getMediaURL(sound) {
if (device.platform.toLowerCase() === "android") {
return cordova.file.applicationDirectory.replace('cdvfile://',
'') + 'www/application/app/' + sound.substr(1);
} else {
return cordova.file.applicationDirectory.replace('cdvfile://',
'') + sound.substr(1);
}
}
Put your sounds in a /www/sounds folder
www/sounds/mysound.mp3
Then load the sound in JavaScript
var sound = new Audio('/sounds/mysound.mp3');
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.