Simple Sound Example using JavaScript on iPhone?

120 views
Skip to first unread message

waca

unread,
May 4, 2009, 6:27:57 PM5/4/09
to phonegap
Hi All--

I've gone through the latest download (0.7.2) and have been reading
through various sound/audio posts here and on the Wiki, but am
stumped.

What I'm trying to do is generate a simple sound on a web page, which
works great everywhere but on the iPhone (it always wants to use the
QuickTime player). So I've been looking into a JavaScript method to
generate sound on the iPhone. All I want to do is "play sound
XYZ.wav".

After diving into QuickConnectiPhone, I discovered PhoneGap, and have
been very encouraged by the simplicity of design (not having an entire
framework included).

But... I cannot figure out how to include the simple javascript
Device.playSound('XYZ.wav'); call because I am unclear as to how to
set up the rest of PG (the PG Class folders, etc.) In fact, I'm
slightly confused as to whether or not I can do this at all without
having to build a custom iPhone app using XCode.


So my question is two-fold:

(1) Can the PhoneGap API be called from the iPhone using only
JavaScript (i.e. from a web page in Safari on the iPhone), without
having to build an actual iPhone App?

(2) If it can, is there a working example of how to set up the folders
on the server with any path substitution (e.g. replace SOURCE_PATH
with your URL) indicated?


Thanks in advance!
--Wayne

Paul Prescod

unread,
May 4, 2009, 7:16:49 PM5/4/09
to phon...@googlegroups.com


On Mon, May 4, 2009 at 3:27 PM, waca <wacr...@gmail.com> wrote:

Hi All--

 
So my question is two-fold:

(1) Can the PhoneGap API be called from the iPhone using only
JavaScript (i.e. from a web page in Safari on the iPhone), without
having to build an actual iPhone App?

No, that would be a security hole. Web apps are not allowed to (for example) read your contact list.
 
(2) If it can, is there a working example of how to set up the folders
on the server with any path substitution (e.g. replace SOURCE_PATH
with your URL) indicated?

I haven't tried it myself, but if you look at "Notification.js" you'll see that this should work:

        new Media('beep.wav').play();

 Paul Prescod


waca

unread,
May 5, 2009, 12:55:07 AM5/5/09
to phonegap
Thanks, Paul -- had a feeling you were going to say that about
(1)... ;)

Guess I'll just have to wait for v3 and actual support for the <audio>
tag. Hope it's coming soon(tm).

Cheers.
Reply all
Reply to author
Forward
0 new messages