![]() |
[HTML/Java] Converting hyperlinks to media files so they open in the background
I'm trying to get hyperlinks to open media files without media player. Closest I've gotten to is the bgsound tag but that only plays background music; no link.
|
So the media files are going to be sounds ? mp3s ?
And you want them played in the browser ? One at a time ? Or a stream ? I'd think that the easiest way to implement something like this is to use a popup window "player" with an embed tag that plays whatever sound/song the user clicks on ? |
Namely wavs. I would assume that the coding would still be the same towards midi and mp3s; if not, slighty modified.
Also, I'm not trying to embed anything. Picture as you may, you have a few media links: (Links are fake so don't bother clicking on them... even though some of you will anyway :lol: ) Chariots Of Fire Please Stand Up Dirt Off Your Shoulder Upon clicking those links, I would like to have the music loaded and played in the background. I know it's possible. |
This may be overkill (I don't know, 'cause I don't code), but the first link on this page: Dee Speaks uses Flash as an interface to play streaming MP3 files.
|
It wouldn't be a sweat with php but I'm guessing you want it plain HTML huh?
A little googling turned this up: http://www.smartwebby.com/web_site_d...play_sound.asp Hope that helps. Although I would like to note that almost everyone hates background sounds on the web and they only sound cool by the owner of the website. I think it's a good thing that you are giving the user the control to decided wether or not to play it though. :) Oh an no MIDIs too... that's good.... MIDIs are evil.... :p |
WHOO-HOO!
Looks like we have a winner: Quote:
<a href="#" onClick="MM_controlSound('play','document.CS1022563046202','sound.wav')">Click Here to Play Sound</a> Edit: Funny. Upon entering the code in a separate HTML file, it appears. But on the TFP the code doesn't work? Odd. Though I found this out, I am still stuck. How do I correctly enter the path of my sound file? Edit edit: D'oh! I had forgotten HTML coding (and I can assume the same for Javascript) has been disabled in this part of the forum. :o |
Glad to have helped :)
Remember that the sound has to be in the location of the web document... I don't know if it will work with a URL... |
Forgot to address this:
Quote:
Quote:
|
Check your browser if you have Javascript off, also check if you put the javascript between the header tags...
There shouldn't be anything in the link, it's just a dummy for javascript... It seems to me that you simply have a javascript problem, then again most of the code IS javascript so that would pretty much be expected... :p If the solutions above didn't do anything at least add an alert("HELLO!"); To the first line of the javascript function, to see if it is executed at all and let me know. I'll try it myself tonite if you're still having probs... |
Works perfectly! :thumbsup:
You see (:o) I didn't use all the code provided on the page. I thought, simply, since I'm using html and they have the sections spread out like this; the feature I was looking for would work regardless of which section I chose or, at least, in three separate, very different ways. Big mistake. I cost myself a couple hours of headaches. Thanks for the help, RelaX. :) Now, all I have left to complain about is the non restarting of the song if you want to listen to it again. Any javascript we could add to that to make it work? Again, thanks RelaX. You've been a big help. :) |
Tell me, why do javascript developers feel a need to bunch their code together? I mean a few newlines aren't goanna make much of a difference for download time....
Anyway, I'm not a javascript person (only had some formal education in Java) but the code below should work. Haven't tested it though, so no guarantees. What it now does is simply performes a stop function on the sound object before playing it, this should ensure it always starts from the beginning. I don't know if this will work on files you're not already playing though... let me know... And copy and paste that URL of the site. ;) Code:
<script language="JavaScript"> |
No go. I'm getting a javascript error.
Quote:
|
I thought that might happen, should've done it right the first time around. Now it first checks if the sound object is actually instantiated yet. I even tested it this time, this works fine for me.
I also changed it to alert a Netscape (or Mozilla) user that it will not work for his/her browser. Code:
<script language="JavaScript"> |
All times are GMT -8. The time now is 04:16 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project