Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

play audio without <embed> or <a href="">?

audio on-demand with simple text links (low bandwidth and no flash)



6:28 pm on Jun 21, 2005 (gmt 0)

10+ Year Member

I have a nice page with a list of 30 audio tracks. I want users to click the title of the track and have it play. If they click another track, the 1st one stops before the 2nd one starts.

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?


6:36 pm on Jun 21, 2005 (gmt 0)

10+ Year Member

curious why you couldn't use flash?


9:08 pm on Jun 21, 2005 (gmt 0)

10+ Year Member

The guy doesn't want it for some inexplicable reason (and here I am with decent flash skills).

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!*.

var playIt=document.getElementById("track");
var stopIt=document.getElementById("audio");

playIt.innerHTML='<embed src="'+trackURL+'" autostart=true hidden=true id="audio" enablejavascript="true">'



<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">'


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.


9:47 pm on Jun 21, 2005 (gmt 0)

10+ Year Member

Way to go :o)

Featured Threads

Hot Threads This Week

Hot Threads This Month