Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Sound-script

  1. #1
    Join Date
    May 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Sound-script

    I wanted to add a soundscript to my homepage, and I found one on these pages.
    But I could not find the .js file which is supposed to be there. It says:

    "The above script references an external .js file, which you can download below:"

    (but I can't find it. I use IE, by the way)

    Any suggestions?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looks like a typo to me, it should read:

    The above script references an external .wav file, which you can download below:
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ah.. I see.. Yes, it could probably be that. I haven't tried the script yet, but I'll give it a go.

    Thank you for helping a silly girl

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    One night I really got into this sound business. Using Google, I found two or three scripts, none of which worked particularly well. I came up with a cross browser script of my own using pieces of the code I had found and bound it all together with a bit of trial, error and common sense. Here is the result:

    HTML Code:
    <html>
    <head>
    <title>Cross Browser Sound - Demo</title>
    <style type="text/css">
    .snd {
    height:0;
    width:0;
    position:absolute;
    top:0;
    left:0
    }
    </style>
    <script type="text/javascript">
    /*Cross Browser Sound Script
      Copyright © John Davenport Scheuer
      Permission granted for use
      This credit must stay intact*/
    //////////No need to Edit Script/////////
    function e_sound(soundobj) {
    if((!document.all)&&(document.getElementById)){
      var thissound= eval("document."+soundobj);
      thissound.Play();
    }
    else if(document.all){
    var a=eval("document.all."+soundobj+".src");
    document.all.sound.src=a;
    }
    else
    return;
    }
    </script>
    </head>
    <body onfocus="if(document.all)document.all.sound.src=''">
    <bgsound id="sound">
    <!--edit below embeds to add different SRC sounds or add more,
    use a unique name for each embed-->
    <embed class="snd" NAME="chm" SRC="chimes.wav" AUTOSTART="false" loop="false" HIDDEN="true">
    <embed class="snd" NAME="dng" SRC="ding.mp3" AUTOSTART="false" loop="false" HIDDEN="true">
    <embed class="snd" NAME="thp" SRC="thup.wav" AUTOSTART="false" loop="false" HIDDEN="true">
    <!--use with any element that supports onMouseOver, onMouseOut or onClick events-->
    <span onmouseOver="e_sound('chm')" onmouseOut="e_sound('dng')">Mouse Over This for Chime, Mouse Out for Ding</span>
    <br><a href=// onmouseOver=e_sound('thp')>Thup!</a>
    </body>
    </html>
    There is virtually nothing non-essential in this demo, as documented, change only the source sounds and the elements receiving sound events. You can use .wav or .mp3 files - small, short sounds are best.
    Last edited by jscheuer1; 05-12-2005 at 09:46 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    One night I really got into this sound business. Using Google, I found two or three scripts, none of which worked particularly well. I came up with a cross browser script of my own using pieces of the code I had found and bound it all together with a bit of trial, error and common sense. Here is the result:

    HTML Code:
    <html>
    <head>
    <title>Cross Browser Sound - Demo</title>
    <style type="text/css">
    .snd {
    height:0;
    width:0;
    position:absolute;
    top:0;
    left:0
    }
    </style>
    <script type="text/javascript">
    /*Cross Browser Sound Script
      Copyright © John Davenport Scheuer
      Permission granted for use
      This credit must stay intact*/
    //////////No need to Edit Script/////////
    function e_sound(soundobj) {
    if((!document.all)&&(document.getElementById)){
      var thissound= eval("document."+soundobj);
      thissound.Play();
    }
    else if(document.all){
    var a=eval("document.all."+soundobj+".src");
    document.all.sound.src=a;
    }
    else
    return;
    }
    </script>
    </head>
    <body onfocus="if(document.all)document.all.sound.src=''">
    <bgsound id="sound">
    <!--edit below embeds to add different SRC sounds or add more,
    use a unique name for each embed-->
    <embed class="snd" NAME="chm" SRC="chimes.wav" AUTOSTART="false" loop="false" HIDDEN="true">
    <embed class="snd" NAME="dng" SRC="ding.mp3" AUTOSTART="false" loop="false" HIDDEN="true">
    <embed class="snd" NAME="thp" SRC="thup.wav" AUTOSTART="false" loop="false" HIDDEN="true">
    <!--use with any element that supports onMouseOver, onMouseOut or onClick events-->
    <span onmouseOver="e_sound('chm')" onmouseOut="e_sound('dng')">Mouse Over This for Chime, Mouse Out for Ding</span>
    <br><a href=// onmouseOver=e_sound('thp')>Thup!</a>
    </body>
    </html>
    There is virtually nothing non-essential in this demo, as documented, change only the source sounds and the elements receiving sound events. You can use .wav or .mp3 files - small, short sounds are best.
    Hi-
    I came upon this thread via the Google search engine searching on "onclick sound" which was exactly what I was looking for. The above quoted posting comes close to exactly what I was looking for but not quite. Exactly what I was looking for is a script that would run in a behavior layer( that is in linked javascript as opposed to embedded JavaScript.) I wanted to have a separate behavior layer the course I have been reading it is the best and most modern programming practice and since I am, a want to be professional, I want to create sites that will impress. I want to do this in hopes that this is a good way to break into the field.

    So I tried the above code first adding an onclick event per HTML comment that this will work to and it did. I then proceeded to cut the script and only the script between the script tags and put it in onload event in a separate page the way I have done at least a few times before and it did not work. I left all the embed tags intact and went over and over my script. All I had in my script was in onload event calling a function with an exact copy of what was between the script tags but it didn't work.

    So I would very much appreciate if somebody here could tell me if it is possible to make this script work that way or alternatively is there another script that one has or I could develop that would work? If I must develop this myself is anyone here have advice as to how to start learning to develop an onclick sound that would run in the behavior layer?

    Anything that could be said here that could help with my above pursuit would be very much appreciated.
    Very sincerely
    Marc

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Also...

    Warning: This is not a Dynamic Drive Script related question.


    Don't worry 'bout that now. ddadmin will probably move the thread anyway.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by jscheuer1
    Here is the result:
    And royally hideous it is too. I'd be fairly surprised if some of that HTML even worked, let alone validated :-\
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
        <title>Cross Browser Sound - Demo</title>
        <style type="text/css">
          .snd {
            display: none;
          }
        </style>
        <script type="text/javascript">
          function playSound(soundobj) {
            if(document.all)
              document.getElementsByTagName("bgsound")[0].src = document.all[soundobj].src;
            else if(document.getElementById)
              document.getElementById(soundobj).Play();
          }
    
          function stopSound(soundobj) {
            if(document.all)
              document.getElementsByTagName("bgsound")[0].src = "";
            else if(document.getElementById)
              document.getElementById(soundobj).Stop();
          }
        </script>
      </head>
      <body onfocus="stopSound('*');">
        <!--[if IE]>
          <bgsound>
        <![endif]-->
    
        <!-- edit below embeds to add different SRC sounds or add more, use a unique ID for each embed -->
        <embed class="snd" id="chm" src="chimes.wav" autostart="false" loop="false" hidden="true">
        <embed class="snd" id="dng" src="ding.mp3" autostart="false" loop="false" hidden="true">
        <embed class="snd" id="thp" src="thup.wav" autostart="false" loop="false" hidden="true">
    
        <!-- use with any element that supports onMouseOver, onMouseOut or onClick events -->
        <p onmouseover="playSound('chm');" onmouseout="playSound('dng');">Mouse Over This for Chime, Mouse Out for Ding</p>
        <p class="falseLink" onmouseover="playSound('thp');">Thup!</p>
      </body>
    </html>
    Untested.
    Last edited by Twey; 11-03-2006 at 04:52 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    And royally hideous it is too. I'd be fairly surprised if some of that HTML even worked, let alone validated
    Agreed. We've come a long way. When was that originally posted? 05-12-2005, over a year ago according to the forum, I'm a fast learner - I haven't been using code quite that bad for a long time now. That code worked at that time but perhaps only in NS 7 and IE 6, and certainly is funky. I have at least one other thread in these forums that either updates that approach or takes a different one that is both prettier to look at and more cross browser. I'll see if I can find it and report back.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, yes. I did wonder about the apparent drop in standard Didn't think to check the date.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, I found a thread that fits this:

    http://www.dynamicdrive.com/forums/s...ead.php?t=7400

    Twey and I worked together there too. It is for onclick events but could as easily be made to be onmouseover/onmouseout events.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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