View Full Version : Help with MP3 player

Nov 5th, 2006, 07:36 PM
Hi, I'm very new to js, and found a cool simple mp3 player script online. I pasted it in to a document labeled testmus.php, but when I load it, all that shows up are the buttons, and when I click the play button nothing happens. I have a feeling I am missing something very simple, but cant figure it out. Any ideas? heres my script

<script language="JavaScript">
var state;

//URL of song - Direct path
function playerinit()
player.settings.autoStart = true ;

//Play Function
function play()
if (player.controls.isavailable('play'))

//Pause Function
function pause()
if (player.controls.isavailable('pause'))

//Stop Function
function stop()
if (player.controls.isavailable('stop'))

<body onload="playerinit();">

<table align='center' width="100%">
<td align="center">
<!-- Default Player Settings -->
<object id="player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="0" height="0">
<param name="autoStart" value="0">
<param name="balance" value="0">
<param name="currentPosition" value="0">
<param name="currentMarker" value="0">
<param name="enableContextMenu" value="0">
<param name="enableErrorDialogs" value="0">
<param name="enabled" value="-1">
<param name="fullScreen" value="0">
<param name="invokeURLs" value="0">
<param name="playCount" value="1">
<param name="rate" value="1">
<param name="uiMode" value="invisible">
<param name="volume" value="100">
<param name="URL" value>
<param name="defaultFrame" value>
<param name="baseURL" value>
<param name="stretchToFit" value="0">
<param name="windowlessVideo" value="0">
<param name="SAMIStyle" value>
<param name="SAMILang" value>
<param name="SAMIFilename" value>
<param name="captioningID" value>
<embed id="player" type="application/x-mplayer2" src="music/test.mp3" height="0" width="0">
<!-- END Default Player Settings -->

<br />

<table align='center'>
<td height="" width="" align="" background="">
<!-- Player Controls -->
<input TYPE="image" src="play.png" value="Play "name="play" onclick="play();"><input TYPE="image" src="play.png"
alt="Pause" value="Pause" name="pause" onclick="pause();"><input TYPE="image" src="stop.png" value="Stop" name="stop"
<!-- END Player Controls -->
</td> </tr>

Nov 5th, 2006, 09:13 PM
What browser are you using? The above will only work in IE because it uses the WMP activex control. Firefox by default has activex support disabled.

Nov 5th, 2006, 09:24 PM
Ohhhh, that makes sense cos Im using firefox. How would I do this for all browsers?

Nov 5th, 2006, 09:41 PM
I would use a flash mp3 player. I like the one found here: http://www.*******************/?item=Flash+Mp3+Player
Its pretty customizable. You don't really need to know flash either. You just need notepad to edit the config files and basic hex color codes. You can use the single song mode or you can use a playlist for multiple songs.