maja88g Posted July 21, 2011 Share Posted July 21, 2011 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 More sharing options...
maja88g Posted July 22, 2011 Author Share Posted July 22, 2011 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 More sharing options...
Ingolme Posted July 22, 2011 Share Posted July 22, 2011 The directory structures you posted are identical. Are you meaning that you used a backslash instead of a forward slash? Link to comment Share on other sites More sharing options...
maja88g Posted July 22, 2011 Author Share Posted July 22, 2011 Sorry I didn't realize that spaces are ignored, hope it makes better sense now? No the backslash is correct, one has a ../(back) and the other ./(forward) Link to comment Share on other sites More sharing options...
Ingolme Posted July 22, 2011 Share Posted July 22, 2011 "./" indicates the same directory. If you want to go up one directory you need to use "../" Link to comment Share on other sites More sharing options...
maja88g Posted July 22, 2011 Author Share Posted July 22, 2011 Okay, but i'm still confused. The structure I showed is the way it is working, it goes to into the sound folder and plays the clip. I need it to go back and play the clip? Link to comment Share on other sites More sharing options...
thescientist Posted July 22, 2011 Share Posted July 22, 2011 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.mp3In 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.mp3since sound folder is IN the same folder as the html file, you would write it assoundfolder/bank_1.mp3./soundfolder/bank_1.mp3 both do the same thing Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.