Jump to content

mp3 wont play with windows media player


maja88g

Recommended Posts

Hi All,I am trying to get a sound file to play when a user clicks on an image, this only has to work in IE, and windows media player should be the only thing used.(Company std)The following is a short version of my code, it works fine when played with other player, but when I try WMP - even tho the player appears it does not autoplay and the play button does not work. Any idea's?

<script language="JavaScript" type="text/JavaScript">	 function playSound(soundfile) 	{	soundfile=soundfile+"1"+".mp3";	alert("here:" + soundfile);	document.getElementById("sound").innerHTML= "<embed src=\""+soundfile+"\" hidden=\"false\" autostart=\"true\" loop=\"false\" />";	 //image_name = "../images/Text Personal Information_"+loglang+".gif";	 	}</script><html>	<headind>SoundTest</heading>	<center>		<h1>Kiosk Sound Test</h1>	</center>	<body bgcolor="steelblue">			<center>				<span id="sound"></span>					<img src="../images/speakerPhoneIcon.jpg" id="butSound" height="50" width="50" onclick="playSound('../sound/bank_')"/>				</center>			<br>						<!--<object type="audio/x-wav" data="../sound/bank_1.wav" width="200" height="45">				<param name="src" value="../sound/bank_1.wav">				<param name="autoplay" value="false">				<param name="autoStart" value="0">				alt : <a href="../sound/bank_1.wav">bank_1.wav</a>			</object>-->			  <form method="get"action="">  </form>	</body><html/>

I have also tried object but I get the same problem, the player displays but doesn't autostart and the play button doesn't work.Thanks

Link to comment
Share on other sites

So I got the above to work if I put the directory forward, then is works. ie - ./sound/bank_ directory structure when it doesn't work:c:----test folder---------html folder-------------------soundtest.html---------sound folder------------------bank_1.mp3------------------bank_2.mp3directory structure when it does work:c:----test folder---------html folder--------------soundtest.html--------------sound folder----------------------bank_1.mp3----------------------bank_2.mp3Any ideas as to why it works with directory forward but not back?Thanks

Link to comment
Share on other sites

right. let's clear it up.

directory structure when it doesn't work:c:----test folder---------html folder-------------------soundtest.html---------sound folder------------------bank_1.mp3------------------bank_2.mp3
In order to get to the sound folder from the folder the html file is in, you need to go up one folder so you are back in test folder, and then go down to sound folder and then to your file. that would be written like this:
../soundfolder/bank_1.mp3

directory structure when it does work:c:----test folder---------html folder--------------soundtest.html--------------sound folder----------------------bank_1.mp3----------------------bank_2.mp3
since sound folder is IN the same folder as the html file, you would write it as
soundfolder/bank_1.mp3./soundfolder/bank_1.mp3

both do the same thing

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...