Forum Moderators: not2easy
Using <embed> makes the page take FOREVER to load, simply referencing the audio with <a href="track.m4a"> makes the browser open a new page, which I don't want. I can't use flash. Any ideas on how to do this?
I just had a brain storm however and figured out a way to do this though with a single <embed> and about 5 lines of java code. My java really sucks, so it took me a while to figure this out, but it works!*.
<script>
playSound(trackURL)
{
var playIt=document.getElementById("track");
var stopIt=document.getElementById("audio");
stopIt.Stop();
playIt.innerHTML='<embed src="'+trackURL+'" autostart=true hidden=true id="audio" enablejavascript="true">'
}
</script>
<body>
<a href="javascript:playSound('play_this.m4a')">Play This</a>
<a href="javascript:playSound('or_this.m4a')">Or This</a>
<a href="javascript:playSound('even_this.m4a')">Even This</a>
<p name="track"><embed src="small.mp3" autostart=false hidden=true id="audio" enablejavascript="true">'
</body>
It seems you have to have an actual audio file already embeded on the page to get this code to work.
*I'm on a different system now, I just tried to copy this from memory,so forgive me for any bugs.