help with something

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

xMikex

Thread Starter
Joined
Nov 7, 2005
Messages
159
Lol i couldnt think of a title. Any ways im trying to do something on my site and i cant seem to get it right. The thing im trying to do can be seen at this site

http://digitalmedia.oreilly.com/2005/02/23/mp3_embed.html

Click the "Play some guitar" link to see what it is im trying to accomplish. I am real new to building site and especially html and javascript so if someone could show me exactly what it is im supposed to do that would be awesome.

Always greatful for your help,

Mike

forgot to say ive tried reading the instructions but alot of it doesnt make sense and he doesnt really say where i place all this code i mean i know it goes on the page but where and its very confusing for a newbie like me.
 
Joined
Apr 14, 2001
Messages
2,382
This is a simple embed function with a popup. Popups are not very effective, and most will be blocked but here is how they did it.

Create a javascript page, name it popup.js.
Copy and paste this into it:
Code:
// JavaScript Document
// Pop-Up Embedder Script by David Battino, www.batmosphere.com; Object tag implementation by Mark Levitt, http://digitalmedia.oreilly.com
var UniqueID = 314 // Make each link open in a new window.
var newWinOffset = 0 // Position of first pop-up
function PlayerOpen(soundfiledesc,soundfilepath) {

PlayWin = window.open('',UniqueID,'width=320,height=190,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
PlayWin.focus(); 
var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE></HEAD><BODY bgcolor='#FF9900'>";
winContent += "<B style='font-size:18px;font-family:Verdana,sans-serif;line-height:1.5'>" + soundfiledesc + "</B>";

winContent += "<OBJECT width='300' height='42'>";
winContent += "<param name='SRC' value='" +  soundfilepath + "'>";
winContent += "<param name='AUTOPLAY' VALUE='true'>";
winContent += "<param name='CONTROLLER' VALUE='true'>";
winContent += "<param name='BGCOLOR' VALUE='#FF9900'>";
winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#FF9900'></EMBED>";
winContent += "</OBJECT>";

winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='"+soundfilepath+"'>Download this file</a> <SPAN style='font-size:10px'>(right-click or Option-click)</SPAN></p>";

winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onClick='javascript:window.close();'></DIV></FORM>";
winContent += "</BODY></HTML>";
PlayWin.document.write(winContent);
PlayWin.document.close(); // "Finalizes" new window
UniqueID = UniqueID + 1
// newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower.
}
Place the javacript page in your servers javascript directory (if you have one set up to store them), or in the root.

Next, on your page you want the links on, place this in the <head> area:
Code:
<script language="JavaScript" type="text/JavaScript" src="popup.js"></script>
note: the src"popup.js" above should reflect the scripts location to the page. If your script is in the pages directory, then it is fine as is. If you move the script the you need to modify that to the script location.

Next, this is the actual link to the javascript popup page and the file
Code:
<a href="example.mp3" target="_blank"
onClick="javascript:PlayerOpen('LFO&amp;#8217;s Revenge',this.href);
return false">Click Me</a>
You need to change the "example.mp3" to the actual file name and location of the mp3 on your server you want the link to open. You can also change the Click Me text to anything, and the file size can be removed if you dont want it listed.
 

xMikex

Thread Starter
Joined
Nov 7, 2005
Messages
159
Sequal7 said:
This is a simple embed function with a popup. Popups are not very effective, and most will be blocked but here is how they did it.

Create a javascript page, name it popup.js.
Copy and paste this into it:
Code:
// JavaScript Document
// Pop-Up Embedder Script by David Battino, www.batmosphere.com; Object tag implementation by Mark Levitt, http://digitalmedia.oreilly.com
var UniqueID = 314 // Make each link open in a new window.
var newWinOffset = 0 // Position of first pop-up
function PlayerOpen(soundfiledesc,soundfilepath) {

PlayWin = window.open('',UniqueID,'width=320,height=190,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
PlayWin.focus(); 
var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE></HEAD><BODY bgcolor='#FF9900'>";
winContent += "<B style='font-size:18px;font-family:Verdana,sans-serif;line-height:1.5'>" + soundfiledesc + "</B>";

winContent += "<OBJECT width='300' height='42'>";
winContent += "<param name='SRC' value='" +  soundfilepath + "'>";
winContent += "<param name='AUTOPLAY' VALUE='true'>";
winContent += "<param name='CONTROLLER' VALUE='true'>";
winContent += "<param name='BGCOLOR' VALUE='#FF9900'>";
winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#FF9900'></EMBED>";
winContent += "</OBJECT>";

winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='"+soundfilepath+"'>Download this file</a> <SPAN style='font-size:10px'>(right-click or Option-click)</SPAN></p>";

winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onClick='javascript:window.close();'></DIV></FORM>";
winContent += "</BODY></HTML>";
PlayWin.document.write(winContent);
PlayWin.document.close(); // "Finalizes" new window
UniqueID = UniqueID + 1
// newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower.
}
Place the javacript page in your servers javascript directory (if you have one set up to store them), or in the root.

Next, on your page you want the links on, place this in the <head> area:
Code:
<script language="JavaScript" type="text/JavaScript" src="popup.js"></script>
note: the src"popup.js" above should reflect the scripts location to the page. If your script is in the pages directory, then it is fine as is. If you move the script the you need to modify that to the script location.

Next, this is the actual link to the javascript popup page and the file
Code:
<a href="example.mp3" target="_blank"
onClick="javascript:PlayerOpen('LFO&amp;#8217;s Revenge',this.href);
return false">Click Me</a>
You need to change the "example.mp3" to the actual file name and location of the mp3 on your server you want the link to open. You can also change the Click Me text to anything, and the file size can be removed if you dont want it listed.

Thank you for your detailed help but if pop ups are not effective then what is the best way to play mp3s on my site?
 
Joined
Apr 14, 2001
Messages
2,382
Yes, unfortunately popups will most likely be blocked and the user will have to disable popups on your site. Not many people will be willing to do that.

The best way is through flash players. If your site can run xml then its a very good alternative. Look at the player in this example on my site, it uses an xml document to store the file location.
Please note, only the first two links actually have files, the rest are null so they wont work.

http://scripts.joyco-webdesign.com/fplayer/
 
Joined
Jan 4, 2006
Messages
112
Popups are usually *NOT* blocked when there is an onclick event taking place, especially if it's from an anchor tag, so there really should be no problem with that script above. Just don't try to run that script from the onLoad event or some sort of a timeout event.
 

xMikex

Thread Starter
Joined
Nov 7, 2005
Messages
159
Sequal7 said:
Yes, unfortunately popups will most likely be blocked and the user will have to disable popups on your site. Not many people will be willing to do that.

The best way is through flash players. If your site can run xml then its a very good alternative. Look at the player in this example on my site, it uses an xml document to store the file location.
Please note, only the first two links actually have files, the rest are null so they wont work.

http://scripts.joyco-webdesign.com/fplayer/
I dont get where your files are in the source. when i try this on my page i just get a big white square on my page and thats it....Can you show what to do because i just simple copied your source code from where i thought the player code started from. I dont get where i put a link to my file in the code.
 
Joined
Apr 14, 2001
Messages
2,382
You need to use the source file on your server, the mp3 files can be anywhere that permits streaming.

PM me to get instruction on how to download from my server, and use this flash player.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top