www.webdeveloper.com
Results 1 to 7 of 7

Thread: .mouseup, .mousedown - paly sound

  1. #1
    Join Date
    Nov 2012
    Posts
    4

    .mouseup, .mousedown - paly sound

    Hello. Ive got a problem, trying to solve it for two days now, but wasnt 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. (Im 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 ive 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, ive tried at least 70 variations but the problem is Im not able to make the sound stop playing when i release the button. I implemented everything Ive found but Im writting it syntactically wrong I guess. (.mouseup, .mousedown). Im not able to add .currentTime=0 (I guess bad syntax again). Next issue, Ive 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

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    can you share online link ? i have tested it with minor modification and it works fine, here is what did i try.


    Code:
    <!DOCTYPE html>
    <html>
    <body>
    <div class="birds" style="width: 100px; height: 100px; border: 1px solid red;">
      <audio src="horse.ogg"> Your browser does not support the audio element. </audio>
    </div>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></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>
    </body>
    </html>

  3. #3
    Join Date
    Nov 2012
    Posts
    4
    Thank you for your responce but perhaps theres a little misunderstanding. My both scripts work but Im not syntactically able to make action currentTime=0 happen (this action should happen after the click, actually when I release the button).

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    still your problem isnt clear

  5. #5
    Join Date
    Nov 2012
    Posts
    4
    Im trying to add a piano on my website. I need 3 actions to happen. When I click on the key it plays sound, when I release the button the first sound stops playing and another one starts to play (reverbation). I need to (or at least I think so) add function .mouseup or similar so the first sound stops playing after releasing the mouse button and the reverbation sound starts to play. I am not able to add that function or if that function is wrong I dont know which function is correct.

  6. #6
    Join Date
    Apr 2006
    Posts
    66
    Suggestion: create an "image map" of keyboard. Then use an "onMouseover" "onMouseout event"

  7. #7
    Join Date
    Nov 2012
    Posts
    4
    hm. no help

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10669 seconds
  • Memory Usage 2,900KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates