homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
Forum Library, Charter, Moderator: open

Site Graphics and Multimedia Design Forum

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)

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)

curious why you couldn't use flash?


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

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)

Way to go :o)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved