views:

1287

answers:

2

I'm currently creating an iPhone web application for piano chords, and I wanted to add an option that would let the user press a Play button and play the selected chord. However, I'm not sure how to do this, or if it's even possible.

Basically, is there any way to programmatically (through Javascript) play a sound file (wav, mp3,...) in the background? (i.e. not leaving the page)

Thanks for any help!

(Keep in mind that I'm developing a web app, so I'm using HTML, CSS & JS, not the native SDK)

+4  A: 

short answer: no

from the docs:

Safari on iPhone plays audio and video in webpages in fullscreen playback mode only.

cobbal
Damn, had a feeling that might be the case. Okay, so assuming that that's okay, I have another question- is it possible to play multiple sounds simultaneously? (Basically I just want to have the single notes as audio files, and then play the correct files simultaneously to create the selected chord sound)
blabus
only if you combine them server-side
cobbal
@cobbal: Hmm, now that's interesting... :) Because truthfully if I could just get it to layer the notes and play the selected chord, I really could care less if it fills the screen temporarily.Would you care to elaborate on that at all? (I assume it'd be done with PHP) Thanks for the help!
blabus
PHP would work. I'm not familiar with it, so I can't say how exactly to do it. The general idea would be to load 2 or more audio files, add the signals, encode it, and send it to the client. Also, if you have a limited number of possible chords, you could compute all of them ahead of time and just serve the sound files statically.
cobbal
A: 

yes you can.

http://www.schillmania.com/projects/soundmanager2/

see it in action at soundcloud.com

mike