1 Reply Latest reply on Mar 28, 2014 8:46 AM by robboerman

    audio - toggle on/off multiple sounds even when they are not currently playing

    resdesign Adobe Community Professional & MVP

      I am wondering if there is a way to stop toggle all sounds even if they are not playing.

       

      What I mean by that is I have several sound files that play one at a time when a slide comes in. I can toggle on/of the current sound but what if I want to toggle all sounds on/off in the compostion even if they are not playing so that when I go to next slide it will be on or off depending what was chosen on the previous slide?

       

      One of the problem would be that I do not want all sounds to be turned back on at the same time but only the current one but I still want to be able to turn off all the sounds if the user decides he does not want to hear sound while at the same time I want the sounds to load automatically on each slide if he has decided to have sound.

       

      Hope this makes sense.

        • 1. Re: audio - toggle on/off multiple sounds even when they are not currently playing
          robboerman Level 4

          didn't have the time to test this code yet.

          but it should work.

          Html5 audio can not be accessed by class, it can only be accessed by id.

           

          so i made this code

           

          $( "audio" ).each(function() {

          var a = $(this).attr("id");

          var audioPlayer = document.getElementById(a)

              audioPlayer.pause();

              audioPlayer.currentTime = 0;

          });

           

          this will find the id of the audios and pause them and reset the time to 0

          ( not really a way to officially stop audio )

           

          or you van just mute it with this code

           

          $( "audio" ).each(function() {

          var a = $(this).attr("id");

          var audioPlayer = document.getElementById(a)

              audioPlayer.muted = true;

          });

           

           

           

          - Rob

          1 person found this helpful