我用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>
答案 0 :(得分:0)
哦,胡言乱语。出现错误
$("intro").prop('muted', true);
$("intro").prop('muted', false);
必须是:
$("video").prop('muted', true);
$("video").prop('muted', false);
看起来这段代码不会将视频设置为id =“ intro”,而是将所有视频(或仅播放的视频)设为静音。 :)