Play local sound file when clicking button

Hello, I’ve tried for a really long time to just play a simple local sound file when clicking a button element.

I looked into an example from

http://www.gajotres.net/playing-native-audio-using-ionic-framework-and-cordova/

But when I ran ionic serve --lab on this example, the GUI and everything looked good but when I clicked Play no audio came out.

I know the cordova plugin for native audio should work but I still haven’t been able to find any examples out there that have just a simple button that plays a local sound.

Any help would be much appreciated. Thank you!

Did you try NativeAudio

it worked with me on real device … make sure ngCordova.js is included

1 Like

I think there are several ways to do it. Two of which are explained here:
1)


2)

1 Like

Does ionic serve --lab not support audio but then a real device simulation does?

@joshseides i think ionic serve --lab just simulate different UI behaviors, iam always using real device to test plugins.

I’m following these instructions word for word and got it to run on a real iPhone but no sound is coming out no matter what I do or press…am I possibly missing some CLI installs? I’m pretty sure I have everything though

I mentioned 2 options how to play audio files. Which one did you choose?

I tried both but for some reason neither worked

Try the second link again.
Make sure you have linked your audio file correctly (is the name correct? Is the path correct?)
For debugging purposes run it in the browser and see what the console is saying.

I’ve tried the second link and even the first one but none of it works.

Is there an issue with the plugin?