简体   繁体   English

无法在Firefox中将HTML5视频标记静音

[英]Unable to Mute HTML5 Video Tag in Firefox

I want to make a video call with webrtc. 我想和webrtc进行视频通话。 I have two streams, one is local and the second one is remote stream. 我有两个流,一个是本地的,第二个是远程流。

In Chrome, I mute my video tag in order not to hear my voice which leads to echo. 在Chrome中,我将我的视频标签静音,以便不听到导致回声的声音。 My HTML tag is like; 我的HTML标签就像;

<video style="position:absolute;right:5px;bottom:5px;display: inline;" class="localVideo" autoplay="autoplay" 
muted="true" 
src="mediastream:3ffffe01-da89-44d9-b9cf-454b11ec6a6a" height="25%" width="25%"></video>

In Firefox muted="true" property not working, so that I hear my own voice. 在Firefox中, muted =“true”属性不起作用,所以我听到了自己的声音。 I tried to set muted propery with many ways in other topics like; 我尝试在其他主题中设置多种方式的静音...

var video = document.querySelector("#movie");     
video.muted = true;

different variations of this code snippet with jquery didn't worked. 这个代码片段与jquery的不同变体没有用。

Then I've decided to add controls property to the video tag, in order to watch how Firefox control buttons works. 然后我决定在视频标签中添加controls属性,以便观察Firefox控制按钮的工作原理。 I've seen that mute button on Firefox controller doesn't works either. 我已经看到Firefox控制器上的静音按钮也不起作用。

This issue occurs in both Firefox 35 and Firefox ESR 31.5 with windows 7 - 8.1, macOS with Yosemite. 使用Windows 7 - 8.1,带有Yosemite的macOS的Firefox 35和Firefox ESR 31.5都会出现此问题。 I get media stream via webrtc libraries localStream. 我通过webrtc库localStream获取媒体流。

Is this a known issue, if so is there any workaround to overcome this issue? 这是一个已知问题,如果有,有什么解决方法可以解决这个问题吗?

Thanks. 谢谢。

I also came across this issue with Firefox, the simplest solution I've found is using the onloadedmetadata event as below: 我也遇到过Firefox这个问题,我发现最简单的解决方案是使用onloadedmetadata事件,如下所示:

 video { width: 200px; height: 200px; } 
 <video src="https://scontent-lhr3-1.cdninstagram.com/t50.2886-16/12930587_1020784647992081_252978711_n.mp4" muted onloadedmetadata="this.muted = true" onmouseenter="play()" onmouseleave="pause()" playsinline> 

Note: There's a better answer in this question 注意:这个问题有一个更好的答案

I also had this problem in FF45. 我在FF45中也有这个问题。 The solution was to set muted in code vs. the DOM. 解决方案是在代码与DOM中设置静音。

$("#browserCheck").get(0)
<video id="browserCheck" class="img-responsive" autoplay="" muted="true">
$("#browserCheck").get(0).muted
false
$("#browserCheck").get(0).muted = true
true
$("#browserCheck").get(0).muted
true

I've had trouble muting video with Firefox, too. 我也无法使用Firefox静音视频。 No problem in Chrome. Chrome没问题。 I worked around the Firefox issue by setting the volume to zero. 我通过将音量设置为零来解决Firefox问题。 Same net effect? 同样的净效应?

var video = document.querySelector("#movie");     
video.volume = 0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM