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.
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.
Originally Posted by Jonny Lang
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.
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...
Code:
// 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>
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.
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?
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...
HTML Code:
<!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.
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?
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.
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.
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...
Code:
<!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>
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"
that should have worked. Are you sure that JavaScript is enabled for the browsers?
copy and paste this into the address bar...
Code:
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"
Bookmarks