osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Run a sound file located on client phone with javascript

Hello. I'm finishing up my app and have a question...

I need to run a sound file on the client handset (iphone). How would I go about doing this in javascript?

I have a timer app, at a set time, the app needs to run a specific WAV file that is located on the users phone. Can you show me the simple code to do this?

Thanks.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Run a sound file located on client phone with javascript

Hi,

There are two ways to implement this:

1) Via PhoneGap http://docs.phonegap.com/en/2.7.0/cor...

2) Using 'audio' HTML tag
code<audio src="URL"><&#47;audio>/codewhere URL is a link to audio file.

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Run a sound file located on client phone with javascript

Thanks Katya. But these examples assumes that the audio file lives on a server. Is there anyway to have it look locally, like where all your other music files are stored?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Run a sound file located on client phone with javascript

Please take a look at the instruction:

order of file search

When only a file name or simple path is provided, iOS will search in the www for the file and then in the application documents/tmp directory.

codevar myMedia = new Media("audio&#47;beer&#46;mp3")
myMedia&#46;play() &#47;&#47; will first look for file in www&#47;audio&#47;beer&#46;mp3 then in <application>&#47;documents&#47;tmp&#47;audio&#47;beer&#46;mp3/code

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Run a sound file located on client phone with javascript

Since I'm testing my appery app as a web app, how would it know to check /documents/tmp/audio/

Should I upload the file to my appery project?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Run a sound file located on client phone with javascript

Hi,

For testing you can upload a file to database, but local path for iPhone should be specified just before testing on device.

Return to “Issues”