4

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)

blabus
  • 795
  • 2
  • 14
  • 25

4 Answers4

4

short answer: no

from the docs:

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

cobbal
  • 69,903
  • 20
  • 143
  • 156
  • 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 Nov 07 '09 at 23:05
  • 1
    only if you combine them server-side – cobbal Nov 08 '09 at 00:21
  • @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 Nov 09 '09 at 04:37
  • 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 Nov 09 '09 at 20:28
  • I went to http://www.schillmania.com/projects/soundmanager2/ on my ipod touch and it plays the sound on the page - not fullscreen. – Yehosef Apr 10 '13 at 12:49
2

yes you can.

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

see it in action at soundcloud.com

mike
  • 36
  • 1
2

With HTML5 audio, iPhone can play without fullscreen.

Peter
  • 21
  • 1
0

IOS requires sound be played with the press of a control button. If you are looking to autoplay a sound at some event on an HTML page, forget it.