Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
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:

Code:
<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:

Code:
<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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.