Delidragon
Delidragon

Reputation: 165

Mute sound (A-frame)

I made an a-scene with an a-videosphere. I try to enable/disable my sound with an button, but it dosn´t work some ideas? Here my code:

     var gargamel = 0;

    function mute_it() {
         gargamel += 1;

         if(gargamel == 1) {
          sound_off();
         }

         if(gargamel == 2) {
           sound_on();
           gargamel = 0;
         }
       }

       function sound_off() {
         $("#sound_button").attr("src","#soicon_off_src");
         $("intro").prop('muted', true);
       }

       function sound_on() {
          $("#sound_button").attr("src","#soicon_on_src");
          $("intro").prop('muted', false);
       }

     <a-assets timeout="0">
        <img id="soicon_on_src" src="footage/bilder/icon_mute.png" crossorigin="anonymous">
        <img id="soicon_off_src" src="footage/bilder/icon mute withoutsound.png" crossorigin="anonymous">
            <video id="intro" style="display:none" preload="none"
                   loop="false" crossorigin="anonymous" playsinline webkit-playsinline>
     </a-assets>

    <a-image id="sound_button" src="#soicon_on_src" onclick="mute_it()"></a-image>

Upvotes: 0

Views: 640

Answers (1)

Delidragon
Delidragon

Reputation: 165

Oh crap im stupid. there was a mistake

 $("intro").prop('muted', true);
 $("intro").prop('muted', false);

must be:

 $("video").prop('muted', true);
 $("video").prop('muted', false);

it looks like this code dosn´t mute the video with the id="intro" its mutes all videos(or only the one which plays). :)

Upvotes: 1

Related Questions