|
|
LinkBack | Thread Tools |
03-18-2004, 10:51 AM | #1 (permalink) |
Addict
|
[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.
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. |
03-18-2004, 10:53 AM | #2 (permalink) |
Psycho
|
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 ? |
03-18-2004, 11:16 AM | #3 (permalink) |
Addict
|
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 ) 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.
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. |
03-18-2004, 11:48 AM | #4 (permalink) |
Devoted
Donor
Location: New England
|
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.
__________________
I can't read your signature. Sorry. |
03-18-2004, 11:51 AM | #5 (permalink) |
Follower of Ner'Zhul
Location: Netherlands
|
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....
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein |
03-18-2004, 12:12 PM | #6 (permalink) | |
Addict
|
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.
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. Last edited by oldtimer; 03-21-2004 at 08:13 PM.. |
|
03-18-2004, 01:09 PM | #7 (permalink) |
Follower of Ner'Zhul
Location: Netherlands
|
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...
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein |
03-18-2004, 07:54 PM | #8 (permalink) | ||
Addict
|
Forgot to address this:
Quote:
Quote:
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. |
||
03-18-2004, 11:21 PM | #9 (permalink) |
Follower of Ner'Zhul
Location: Netherlands
|
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... 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...
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein Last edited by RelaX; 03-18-2004 at 11:24 PM.. |
03-19-2004, 10:38 AM | #10 (permalink) |
Addict
|
Works perfectly!
You see () 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.
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. |
03-19-2004, 11:59 AM | #11 (permalink) |
Follower of Ner'Zhul
Location: Netherlands
|
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"> <!-- //v3.0 function MM_controlSound(x, _sndObj, sndFile) { var i; var method = ""; var sndObj = eval(_sndObj); if (sndObj != null) { if (navigator.appName == 'Netscape') { method = "play"; } else if (window.MM_WMP == null) { window.MM_WMP = false; for(i in sndObj) { if (i == "ActiveMovie") { window.MM_WMP = true; break; } } } if (window.MM_WMP){ { method = "play"; } else if (sndObj.FileName) { method = "run"; } } } if (method) { eval(_sndObj+".stop()"); eval(_sndObj+"."+method+"()"); } else { window.location = sndFile; } } //--> </script>
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein |
03-20-2004, 09:20 AM | #12 (permalink) | |
Addict
|
No go. I'm getting a javascript error.
Quote:
__________________
Slowly but surely getting over the loss of TFP v. 3.0. Where the hell am I?.... Showering once a month does not make you a better person. "The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." Martin Luther King, Jr. |
|
03-21-2004, 02:12 PM | #13 (permalink) |
Follower of Ner'Zhul
Location: Netherlands
|
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"> <!-- //v3.0 function MM_controlSound(x, _sndObj, sndFile) { var i; var method = ""; var sndObj = eval(_sndObj); if (sndObj != null) { if (navigator.appName == 'Netscape') { alert("My appologies, this functionality is reserved for Internet Explorer users only"); method = "play"; } else { if (window.MM_WMP == null) { window.MM_WMP = false; for(i in sndObj) { if (i == "ActiveMovie") { window.MM_WMP = true; break; } } } if (window.MM_WMP) { method = "play"; } else if(sndObj.FileName) { method = "run"; } } } if (method) { if (sndObj != null) { eval(_sndObj+".stop()"); } eval(_sndObj+"."+method+"()"); } else { window.location = sndFile; } } //--> </script>
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. - Nathaniel Borenstein Last edited by RelaX; 03-21-2004 at 02:22 PM.. |
Tags |
background, converting, files, html or java, hyperlinks, media, open |
|
|