静音和取消静音按钮切换音频HTML5 [英] mute and unmute button toggle html5 audio

查看:2200
本文介绍了静音和取消静音按钮切换音频HTML5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何忽略一个<音频> 通过把此code声音对象:

 < A HREF =#的onclick =的document.getElementById('氛围')静音= TRUE;返回false>
    静音
&所述; / A>

现在我在寻找如何静音/使用相同的按钮,选择钮可解除静音我​​的声音?

谁能告诉我怎么走?


解决方案

  VAR audioElm =的document.getElementById('氛围'); audioElm.muted = audioElm.muted!;

I've understood how to mute an <audio> sound object by putting this code :

<a href="#" onclick="document.getElementById('ambiance').muted = true; return false">
    mute sound
</a>

Now I'm searching how to mute/unmute my sound using the same button with the option to toggle it ?

Can anyone give me directions?

解决方案

var audioElm = document.getElementById('ambiance'); audioElm.muted = !audioElm.muted;

这篇关于静音和取消静音按钮切换音频HTML5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆