A
alice
I've been trying for a long time to figure this out, to have a page
with several MP3 clips, and each one having a custom start and stop
button next to them to play the track. I finally found a bit of code
that does this, but it's made for only one mp3 file. I don't know
enough about javascript to customize the code myself. I know there
probably needs to be an "array" of some sort, but I need some help
figuring out where and how that works.
Here's the code I found
<script language="JavaScript">
var state;
//URL of song - Direct path
function playerinit()
{
player.url="YOURSONG";
player.settings.autoStart = true ;
}
//Play Function
function play()
{
if (player.controls.isavailable('play'))
{
player.controls.play();
state=setInterval("updatetime()",1000);
}
}
//Stop Function
function stop()
{
if (player.controls.isavailable('stop'))
{
player.controls.stop();
clearInterval(state);
}
}
</script>
</head>
<body onload="playerinit();">
<!-- START PLAYER -->
<!-- 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="" height="0"
width="0">
</object>
<!-- END Default Player Settings -->
<br />
<!-- Player Controls -->
<input TYPE="image" src="PLAYBUTTONHERE.gif" value="Play "name="play"
onclick="play();">
<input TYPE="image" src="STOPBUTTONHERE.gif" value="Stop" name="stop"
onclick="stop();">
<!-- END Player Controls -->
with several MP3 clips, and each one having a custom start and stop
button next to them to play the track. I finally found a bit of code
that does this, but it's made for only one mp3 file. I don't know
enough about javascript to customize the code myself. I know there
probably needs to be an "array" of some sort, but I need some help
figuring out where and how that works.
Here's the code I found
<script language="JavaScript">
var state;
//URL of song - Direct path
function playerinit()
{
player.url="YOURSONG";
player.settings.autoStart = true ;
}
//Play Function
function play()
{
if (player.controls.isavailable('play'))
{
player.controls.play();
state=setInterval("updatetime()",1000);
}
}
//Stop Function
function stop()
{
if (player.controls.isavailable('stop'))
{
player.controls.stop();
clearInterval(state);
}
}
</script>
</head>
<body onload="playerinit();">
<!-- START PLAYER -->
<!-- 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="" height="0"
width="0">
</object>
<!-- END Default Player Settings -->
<br />
<!-- Player Controls -->
<input TYPE="image" src="PLAYBUTTONHERE.gif" value="Play "name="play"
onclick="play();">
<input TYPE="image" src="STOPBUTTONHERE.gif" value="Stop" name="stop"
onclick="stop();">
<!-- END Player Controls -->