1 Reply Latest reply on May 1, 2014 11:17 AM by Fred Tacon

    Are there audio events in Edge Animate 3.0? - Need to know when an audio file stops

    Fred Tacon Level 1

      I am working on a project where there is an audio play button.  When the user clicks and the audio plays, I want to show a highlighted version of the button, but when the audio finishes, I want to highlight to hide again.

       

      I have done this successfully using the buzz.js library, but I am trying to use Animates new native audio support, and I am hoping I can accomplish the same thing.  With buzz, I would to this...

       

       

      arm.bind("pause", function(e) {

          sym.$("play_arm").attr("src","images/play_btn.png");

      });

      arm.bind("playing", function(e) {

          sym.$("play_arm").attr("src","images/stop_btn.png");

      });

       

       

      In this instance, "arm" is a variable containing the audio file, and I am binding it to the "pause" and "paying" events thrown by buzz.

       

       

      This syntax does not work for native audio, so I am wondering if there is a different way to accomplish this, or if there are no usable events.

       

      Any suggestions will be greatly appreciated.  Thanks!

       

      Fred

        • 1. Re: Are there audio events in Edge Animate 3.0? - Need to know when an audio file stops
          Fred Tacon Level 1

          Got it.

           

          Instead of binding the action to the event, you add an event listener. So...

           

          arm.bind("pause", function(e) {

              sym.$("play_arm").attr("src","images/play_btn.png");

          });

           

          becomes

           

          arm.addEventListener('ended', function(){

               ...

          });

           

          You will also notice that I used 'ended' instead of 'pause'.  My audio files play all the way through in my current project, so 'ended' is the best event.  'Pause' also fires at the end, so really you can use either.

           

          Hope this helps anyone who encounters the same issue.  Thanks!

           

          Fred