I trying to play sample audio files stored in www/assets/audio/
folder.
Tried NativeAudio provider, HTML5 audio, to create Media instance. But none of those worked.
Could anybody help me with this issue?
Any error log? Code snippets?
If none of the methods you used weren’t working, check the path/url of the audio file if it was correct or not.
I’ve 2 functions in my page:
playAudio() {
this.nativeAudio.preloadSimple('uniqueId1', 'assets/audio/music.mp3').then(
success => {
console.log(JSON.stringify(success));
this.nativeAudio.play('uniqueId1');
},
error => {
console.error(JSON.stringify(error));
}
);
}
playAudioHTML5() {
const audio = new Audio();
audio.src = 'assets/audio/music.mp3';
audio.load();
audio.play();
}
hitting playAudio
gives
console.error: “(NATIVE AUDIO) Asset not found. (assets/audio/music.mp3)”
playAudioHTML5
does nothing, but works on android
Use normalizeURL function everywhere, also try preloadComplex() instead of preloadSimple() method. preloadSimple() had some issue on some platforms in the past but I don’t know what’s the actual status.