PDA

View Full Version : Sound possible in iPhone SDK's webform?




Danneman101
Sep 25, 2008, 03:16 AM
Im wondering if its possible to play a sound (preferably an .mp3-file) by pushing a button in the integrated webform of the sdk.

For instance by using a similar javascript-code in an html-form:


<script type="text/javascript">
var sound2Embed = null;


function sound2Play() {
if ( !sound2Embed ) {
sound2Embed = document.createElement("embed");
sound2Embed.setAttribute("src", "machinegun.wav");
sound2Embed.setAttribute("hidden", true);
sound2Embed.setAttribute("autostart", true);
} else sound2Stop();
sound2Embed.removed = false;
document.body.appendChild(sound2Embed);
}
</script>




Alternativevly, this code works in regular browsers too:


<a href="sound/roedy.mp3"><img src="image/audio/mp3.png"
alt="Voice" border="0"
width="24" height="32"
align="absmiddle"></a>


However, it does load a separate page instead of just playing the sound. Is there a way around this (if sound even is possible with this approach)? I just want the sound playing from pressing an icon.