简体   繁体   English

静音(A 帧)

[英]Mute sound (A-frame)

I made an a-scene with an a-videosphere.我用 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>

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).看起来这段代码不会将带有 id="intro" 的视频静音,它会将所有视频(或仅播放的视频)静音。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM