静音(A 帧)
Mute sound (A-frame)
我用 a-videosphere 制作了一个场景。我尝试使用按钮 enable/disable 我的声音,但有些想法不起作用?这是我的代码:
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" 的视频静音,它会使所有视频(或仅播放的视频)静音。 :)
我用 a-videosphere 制作了一个场景。我尝试使用按钮 enable/disable 我的声音,但有些想法不起作用?这是我的代码:
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" 的视频静音,它会使所有视频(或仅播放的视频)静音。 :)