Click to See Complete Forum and Search --> : Sound file not playing


CEG5454
07-28-2005, 02:39 PM
Hi,
I am a research coordinator at a
Children's Hospital. My group and I are using a
program called MediaLab to develop a questionnaire for our subjects. We
have run into a snag that I'm hoping you will be able to help us
resolve. Someone from our project had contacted the company
about using an html file in our questionnaire that would
allow us to play a wav file when it was clicked on. We have used the
file that was sent to us. However when we run the experiment and
click on the html file we get an error message and the wav file does
not play on two of the 3 tablet pcs we are using. I have worked with the IT
department to trouble shoot the
problem and have not been able to resolve it. The template they sent us
contains Java script. The error message that we get says:
Error: object doesnt support this property or method.

Having the Javascript rewritten got rid of the error message but the sound file still
does not play.


Any help would be greatly appreciated.

OptamumPC
07-28-2005, 02:47 PM
giv us some code man!

CEG5454
07-28-2005, 03:57 PM
Hey,
I have attached an example of the original script and a wav. file. Below is the new code that was written for me. The new code doesnt return the error message but the wav. file still doesnt play. I only get a clicking sound.




Try the following for clicking a text link to play a .wav file. The third file in the array, sometimes.wav, is an example of using a "path". The sometimes.wav file is in a folder named: media The others are in the same folder as the main document.

The code is IE only, and I tested it with your yes.wav file.

<HTML>
<Head>
<Script Language=JavaScript>

audioFX = new Array()
audioFX[0] = "yes.wav";
audioFX[1] = "no.wav";
audioFX[2] = "media/sometimes.wav";

function playWav(isWav){

isSelection = audioFX[isWav];
embedStr = "<Embed Src="+isSelection+" Width=0 Height=0></Embed>"
document.getElementById('isEmbed').innerHTML = embedStr;
}

</Script>
</Head>
<Body>
<Div id='isEmbed'></Div>
<a href=javascript:playWav(0)> Yes </a><br>
<a href=javascript:playWav(1)> No </a><br>
<a href=javascript:playWav(2)> Sometimes </a>
</Body>
</HTML>

BeachSide
07-28-2005, 09:19 PM
Have you given any thought to using something like Flash? Also making that an mp3 would probably be good too

You don't have to do those things they are just suggestions

Last but not least that code up there is not correct which is probably why it doesn't work properly.

I am assuming that this is a closed network that your subjects are using? So you are using Windows with IE 6

BeachSide
07-28-2005, 09:59 PM
Just to show how unnecessary all that mumbojumbo is that they gave you here is one that will work all you need to do is replace yes.wav in any links you have. For example...

// if you have this link for yes
<a href="yes.wav" onclick="song('yes.wav'); return false;">yo run the script and it will say YES</a>

// then you change yes.wav to no.wav for it to play the no sound
<a href="no.wav" onclick="song('no.wav'); return false;">yo run the script and it will say NO</a>


Here is the code...

<html>
<head>
<script type="text/javascript">
function song(songName) {
document.write('<embed autostart="true" height="0" width="0" loop="false" src="' + songName + '"></embed>');
}
</script>
</head>
<body>
<a href="yes.wav" onclick="song('yes.wav'); return false;">yo run the script</a>
</body>
</html>


::Edit:: Oh and btw for what it is worth my version is the accessible version ;) their's is not

I hate it when people use "javascript;" in the <a></a> tag :mad:

CEG5454
07-29-2005, 12:03 AM
Thanks for the suggestions and taking the time to write a new script!
I will give the code you sent me a try when I get into work tomorrow and I'll let you know if this does the trick.

CEG5454
07-29-2005, 09:34 AM
Hey no luck,
The script runs fine when I open it in IE except that a media player window pops up. But when I plug it into the media player program I get two error messages. I'm attaching them. I think the problem must lye in the tablets not the code. There must be some setting or maybe its a permissions issue(although everything does work on the one tablet). Any thoughts?

BeachSide
07-29-2005, 10:41 AM
Just curious did you copy and paste that line with the <a> tag into your code or did you hand type it. Because in the one I did it is not missing a ";"

anyway since it is bringing up the media player we will just go about it a different way then ;)

We will use it a background sound. Try this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function song(songName) {
document.write('<bgsound loop="0" src="' + songName + '">');
}
-->
</script>
</head>

<body>
<a href="yes.wav" onclick="song('yes.wav'); return false;">yo run the script</a>
</body>
</html>


Oh and btw it shouldn't have opened the windows media player, actually it would but you should have not been able to see it. Your IE has it set somewhere to open these files in an external player.

BeachSide
07-29-2005, 12:14 PM
I just thought about it and realized that the code above is not going to work like you want it to. What do you want to happen after the user clicks the link?

CEG5454
07-31-2005, 01:26 AM
Hey,
I want the sound file to play but I don't want the media player to pop up. You think its an IE setting? I tried to compare the settings between the tablet that works and the 2 that dont. I thought I had checked everything, But I might have missed something.

BeachSide
07-31-2005, 11:38 PM
no I mean what do you want to happen after the link is clicked? I'll write the proper code for it.

We'll use it as a background sound to bypass the Win Media Player no matter the setting.

CEG5454
08-02-2005, 09:11 AM
Hey, How it works with the media lab program is that a question is asked and there are multiple response buttons with html links below them. When the subject clicks on the link they are supposed to here the sound file play. The program is set up this way to accomodate young children who might have difficulty reading. But thats all that happens. You click the link and the sound file plays.

BeachSide
08-02-2005, 12:24 PM
Ok no problem, I have a few things to do first then I will whip something up for you

::Edit:: Try this and make sure it works before we move forward

Note: for this to work you will need yes.wav, no.wav, sometimes.wav, yes.htm, no.htm, sometimes.htm, and put this in index.htm
(see attached .zip for the .htm files I'll leave the .wav files up to you)

The code is as follows...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<bgsound src="#" loop="0" autostart="true" id="soundFile">
<script type="text/javascript">
<!--
// Here is a quick script so you can hopefully see what is going on and how to play the sound
// if you need further help let me know
// I obviously do not know what the links need to be therefore
// this is a generic script to show the functionality
function gotoNextPage(page) {
// This function redirects the browser to your new page based upon the yes, sometimes, or no input
window.location=page + '.htm';
}

function playSound(sound) {
// Play the sound and go to the proper link
document.all.soundFile.src="" + sound + ".wav";
window.setTimeout("gotoNextPage('" + sound + "');",2000);
}
-->
</script>
</head>
<body>
<p><a href="yes.htm" onclick="playSound('yes'); return false;">Yes</a> | <a href="sometimes.htm" onclick="playSound('sometimes'); return false;">Sometimes</a> | <a href="no.htm" onclick="playSound('no'); return false;">No</a></p>
</body>
</html>

CEG5454
08-03-2005, 02:42 PM
Hey no luck. When I tried it outside of media lab the yes no or sometimes page came up but without a sound. When I tried it in media lab it looks like a "this page cannot be displayed page opened up"

BeachSide
08-03-2005, 02:46 PM
Hmmm interesting...

that should have worked. Are you sure that JavaScript is enabled for the browsers?

copy and paste this into the address bar...

javascript: document.write("<h1>Working!</h1>");


::Edit:: If that is not working, does Flash work on your tablets? If so here is a zip file there is an index.htm and choose.swf in it. See if that will work, if it does and JavaScript is not an option I will fix it up so that it you will basically only have to create a .txt file with the links and when the child hits the button it will go to that link after saying "yes" "no" or "sometimes"

CEG5454
08-09-2005, 01:50 PM
Hey sorry I havent been on in a few days. we were working with our subjects and I didnt have any time to trouble shoot. I'll try the two thing you sent me and let you know how it works.
thanks

CEG5454
08-09-2005, 02:05 PM
The script gave me the line that says working. But flash is not on the tablets. when I opened you folder windows wanted to know what program to open the file with.

BeachSide
08-09-2005, 06:25 PM
Ok so the script that you typed into the address bar worked. This is good that means JavaScript is in fact working.

But all the scripts that we have tried thus far have not worked... hmmmm... ok let me try somethings and see what we can come up with.

As for the Flash thing, that is fine no big deal. It just meant you needed to install the Flash Player Plugin which if you want you can find here (http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash)

I would recommend going with JavaScript though as using Flash for what your doing is kinda like using a 10lb hammer to drive a finishing nail, overkill imo.

Up to you though bud. Whatever you want.

CEG5454
08-11-2005, 09:20 AM
Honestly, I just want something that works. This has been going on for awhile now and no one from IT has even been around to work on these machines. It's annoying because I dont have admin rights so I'm limited in what I can and cant do. I do appreciate your help. Its very cool of you to take the time to try to troubleshoot someone elses problem.

Chris

CEG5454
08-12-2005, 09:43 AM
Hey,
late yesterday I tried converting the wav files to mp3 and it worked!
This is good for a workaround but I'm curious as to why Mp3 files work but wav files dont. Any thoughts?

Oh and thank you for the help along the way

BeachSide
08-12-2005, 06:24 PM
It's in your settings somewhere that wav files need to opened with media player only if it is to be opened automatically.

Glad to see you got it working :D

My g/f is a psyc major so I understand working with things like that are important and I like doing it "for the kids" ;) lol cliche I know...

Anyway no problem man that's one of the main reasons I come here... to help :p

marymccann1960
02-22-2007, 05:57 PM
Hello...if anyone is still interested in this issue, I have found that the following works (IE Only):

Place the following link to your .wav file (named YOURWAV.WAV here)

<a href="#" onclick="document.all.music.src='YOURWAV.WAV'">YOURWAV</A>


Then, place the following code on your page:

<bgsound src="#" id="music" loop="1" autostart="true">


When the link is clicked, the wav file will play. The only thing I don't like about it is that when the link is clicked you are returned to the top of the page. Anyone know how to fix it so you stay where you are?

Thanks.
Mary