I see this is a common question and i’ve found lots of tutorials and questions here, but all of them was for recording files and what i need is to play existing files in my app.
I have the following folder structure:
src |_ assets |_ sounds |_ mysound.wav
The mysound.wav is a file i’ve downloaded and i’m following the same protocol for other files, i simply put it inside assets and in the build it goes to the right place, the cade is where’s that place?
i’ve tried with the normal “…/assets/sounds/mysound.wav” with a simple public myvar: any = new Audio(‘path’) but it throws this error:
GET file:///android_asset/assets/sounds/Duel%20Victory.wav net::ERR_FILE_NOT_FOUND
So i’ve found some post saying about using the media plugin. I’ve installed it and now i’m doing this way:
// THEY'RE ALL VALID FILES public corretoAudio: MediaObject = this.media.create('file://assets/sounds/Correct.wav'); public erroAudio: MediaObject = this.media.create('file://www/assets/sounds/Incorrect.wav'); public iniciarAudio: MediaObject = this.media.create('file://Iniciar.wav'); public contagemAudio: MediaObject = this.media.create('file://audio/Countdown.wav');
All these paths are different examples i’ve found around the web, but none of them plays the any audio and neither throw any error when i use success/error callbacks.
What’s is the correct filepath in that case? how can i play there audios? I’m starting to think that the best way is to store them somewhere and get via HTTP.
Any help is appreciated.