How to play a sound on iOS? (Ionic Media Documentation is very bad)


#1

Hi everyone.

I’m currently trying to play a sound on iOS.

I first tried using the Native Audio plugin. Couldn’t get it to work. Turns out it according to this it doesn’t work (why, dear Ionic Team, keep it in the docs then)?

So I tried the solution mentioned there. I used Media.
Turns out this also doesn’t work and even after googling extensively I couldn’t get it to work.

The error I get is always:

Unknown resource '../../../platforms/ios/www/assets/audio/lecker.mp3'

Or some kind of variation of that depending on what I tried for the file path.
Does any one know how to get Media to use the correct ressource?
In my Ionic project the path to my file is:

/src/assets/audio/lecker.mp3/

And the path to the page where I use media is:

/src/pages/home/home.ts/

So the relative path should be:

../../assets/audio/lecker.mp3

Any help would be much appreciated!


#2

Push. Does anyone have an answer for this? It is really important for me…


#3

Found it! After hours of struggle and the (very bad) documentation here is the filepath that worked:

'./assets/audio/lecker.mp3'

Doesn’t make any sense, but works.