[Native Audio Plugin] How to use Native Audio Plugin

[Native Audio Plugin] How to use Native Audio Plugin

  
Forge Component
(1)
Published on 2017-03-07 by Miguel 'Kelter' Antunes
1 vote
Published on 2017-03-07 by Miguel 'Kelter' Antunes

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?

Solution

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();


Solution

Davidk wrote:

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();


Thanks! It was the Deploy Action that did the trick.