gpt4 book ai didi

javascript - 静音(A 型)

转载 作者:行者123 更新时间:2023-12-03 01:23:29 29 4
gpt4 key购买 nike

我用 a-videosphere 制作了一个 a-scene。我尝试使用按钮启用/禁用声音,但有些想法不起作用?这是我的代码:

     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>

最佳答案

哦,糟糕,我太蠢了。有一个错误

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

必须是:

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

看起来此代码不会将 id="intro"的视频静音,而是将所有视频静音(或仅播放正在播放的视频)。 :)

关于javascript - 静音(A 型),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51653558/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com