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

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

问题描述

我已经了解如何通过放置以下代码来使 <audio> 声音对象静音:

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 ?

谁能给我指路?

推荐答案

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

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

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