Hi,
I'm trying to play a sound in a mobile application. The sound file has been imported as a resource. I've tried using a JavaScript like this
var audio = new Audio('/MyApp/mySound.mp3');audio.play();
but that does not work (on an iPhone).
So I tried the NativeAudioPlugin, but that does not work either. I first call CheckNativeAudioPlugin, which apparently returns Available, and then Play with the same URL as above in the SoundName input parameter. I then check ErrorCode, which apparently is empty, and then display a message that Play was called. The message is displayed, but I hear no sound.
What am I doing wrong or not doing that should be done first?
Your code will work... and you don't need the plugin... but you must remember to Deploy the mp3 file. I just tested this and it works as it should. You might also have a look at the Public property... see if you want to do that as well... however its setting has no effect on playing the audio file.
These are my settings... and this is my code...
var audio = new Audio('/SocialShareTest/mpthreetest.mp3');audio.play();
Davidk wrote:
Thanks! It was the Deploy Action that did the trick.
What if I'm not having the audio in my resource , Instead I'm using audio recorder plugin which returns a audiofile with filename and path. Using file plugin's savefile action i"m getting the uri and using this uri to play the audio using JS
var audio=new.Audio(savefile.uri);
audio.play();
Following this approach my audio is not getting played , Recommendations would highly be appreciated!