View Full Version : Prob when trying to add music to my site...

12-19-2005, 02:17 AM
I am trying to add a button, (just a link now, but will change to a graghic image later), so that visitors to my page can click it and listen to music while they visit my page.

So, I added this line to my code...

<a href="Music_1.mp3">Play music</a>

However, when the 'Play Music' link is hit, it asks me to download the Music before playing it everytime. It will download the music (from my server, I believe, then it plays it OK).

It should not do that, ... and, I have double checked that the file 'Music_1.mp3' is indeed, listed on my FTP server.

I did notice that because of space, only about 90% of the file got uploaded to my server. So, is that the problem? Or do I need more code?

Or, is it not posible to have it play automatically by just hitting the link?

Any help or links to info on this would be greatly appreciated.


12-19-2005, 02:29 AM
Its behaving correctly. To get it to play without the user having to download it, you need a bit more code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
body {
#music {
<script type="text/javascript">
function PlayIt(what){
document.getElementById('music').innerHTML='<object width="1" height="1" '
+'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
+'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
+'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
+'<param name="url" value="'+what+'">'
+'<param name="uiMode" value="full">'
+'<param name="autoStart" value="true">'
+'<param name="loop" value="true">'
+'<embed type="application/x-mplayer2" '
+'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
+'showcontrols="true" uimode="full" width="1" height="1" '
+'src="'+what+'" autostart="true" loop="true">'
function StopIt(){

<a href="http://absolutepathtosong.mp3" onclick="PlayIt(this.href);return false">Song 1</a><br>
<a href="#" onclick="StopIt();return false;">Stop</a>
<div id="music">
<object width="1" height="1"
standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
<param name="url" value="null.mp3">
<param name="uiMode" value="full">
<param name="autoStart" value="true">
<param name="loop" value="true">
<embed type="application/x-mplayer2"
showcontrols="true" uimode="full" width="1" height="1"
src="null.mp3" autostart="true" loop="true">

12-19-2005, 02:38 AM
sweet code there :) i use a code that is similar. I would suggest also some flash mp3 players :)

12-19-2005, 03:12 AM
Thanks for the quick and complete reply. I had seen some examples of code that used a function before, but I thought I only needed all of that if 'I' controlled the music, and thought I only needed 1 line if the 'visitor' clicked it.

Thanks for the info, and for your detailed example and function coding.