www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Sound file not playing

  1. #1
    Join Date
    Jul 2005
    Posts
    14

    Sound file not playing

    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.

  2. #2
    Join Date
    Apr 2005
    Posts
    38
    giv us some code man!

  3. #3
    Join Date
    Jul 2005
    Posts
    14
    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.




    Quote 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.

    Code:
    <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>
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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

  5. #5
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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>
    Here is the code...
    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
    Last edited by BeachSide; 07-28-2005 at 11:04 PM.

  6. #6
    Join Date
    Jul 2005
    Posts
    14
    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.

  7. #7
    Join Date
    Jul 2005
    Posts
    14
    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?
    Attached Files Attached Files

  8. #8
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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.

  9. #9
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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?

  10. #10
    Join Date
    Jul 2005
    Posts
    14
    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.

  11. #11
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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.

  12. #12
    Join Date
    Jul 2005
    Posts
    14
    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.

  13. #13
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    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>
    Attached Files Attached Files
    Last edited by BeachSide; 08-03-2005 at 09:58 AM.

  14. #14
    Join Date
    Jul 2005
    Posts
    14
    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"

  15. #15
    Join Date
    Jan 2005
    Location
    Lithia Springs, GA USA
    Posts
    886
    Hmmm interesting...

    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"
    Attached Files Attached Files
    Last edited by BeachSide; 08-03-2005 at 04:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles