JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2012, 12:04 PM
essentialis essentialis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 essentialis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 39 sec
Reputation Power: 0
.mouseup, .mousedown - paly sound

Hello. I´ve got a problem, trying to solve it for two days now, but wasn´t lucky enough to find solution so far. I hope you might help me. I need a script which plays a sound whenever I click on a picture, but when I release the mouse button the sound stops playing and another sound will play. (I´m trying to implement a piano on my web, the picture are the keys, first sound is the note, second sound is reverberation) This is what i´ve got so far:

Code:
<section id="two">
      <div class="inside">
            <div id="nav-two" class="nav">
                  <audio id="beep-two">
                        <source src="piano/E5.mp3" controls></source>
                        <source src="piano/E5.ogg" controls></source>
                        Your browser does not support that. Please get a new version.
                   </audio>
<a
      onMouseOver="self.document['obrazek3'].src='piano/a_001.png'"
      onMouseOut="self.document['obrazek3'].src='piano/001.png';"
      onMouseDown="self.document['obrazek3'].src='piano/b_001.png';">  
      <img id="obrazek_id_3" name="obrazek3" style="margin-left: 100px; position: absolute;" hspace=5 src="piano/001.png" border="0">
</a>
</div>
            <script>$("#nav-two a")
              .each(function(i) {
                if (i != 0) { 
                  $("#beep-two")
                    .clone()
                    .attr("id", "beep-two" + i)
                    .appendTo($(this).parent()); 
                }
                $(this).data("beeper", i);
              })
              .mousedown(function() {
                $("#beep-two" + $(this).data("beeper"))[0].play();
              });
            $("#beep-two").attr("id", "beep-two0");</script>
      </div>
</section>


Script for one key, i´ve tried at least 70 variations but the problem is I´m not able to make the sound stop playing when i release the button. I implemented everything I´ve found but I´m writting it syntactically wrong I guess. (.mouseup, .mousedown). I´m not able to add .currentTime=0 (I guess bad syntax again). Next issue, I´ve tried (with help of Google xD) to make one script using "hover" nevertheless it works the way that it plays the sound when I move the cursor into the key area and thats not what I need again.
Code:
  <script src="(URL address blocked: See forum rules)"></script>

    <div class="birds">
    <audio src="piano/C5.ogg" preload="auto"></audio>
    </div> 

    <script language="javascript" src="(URL address blocked: See forum rules)"></script>

    <script type="text/javascript">
    $(function(){
    var birdhover     = $('.birds');
        var birdaudio = birdhover.find('audio')[0];

    birdhover.hover(function(){
       birdaudio.play();
    }, function(){
       
       var audioElm = document.getElementById('soundTour');
       birdaudio.currentTime=0;
       birdaudio.pause();

    });
});
    </script>


Reply by illustrative demonstration please

THX

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > .mouseup, .mousedown - paly sound

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap