问题描述
W3C http://www.w3.关于媒体流生命周期的org/TR/mediacapture-streams/#life-cycle-and-media-flow 文章说:
是否提到了在Chrome中实现的行为?
Is mentioned behaviour implemented in Chrome or not?
推荐答案
更新::Firefox现在支持在静音状态下关闭相机灯.在 粗体中进行编辑strong> .
Update: Firefox now supports turning off the camera light on mute. Edits in bold.
我从这个主题中得知,你知道答案是否定的.
I gather from the subject that you know the answer is no.
在站点(临时)禁用摄像机流时,Chrome和Firefox均不会关闭摄像机灯.规范说可以"关闭它,但必须"使其重新打开,因此两种浏览器都符合要求.
Neither Chrome nor Firefox turn off the camera light while a site (temporarily) disables a camera stream. The spec says "can" for turning it off, but "MUST" for turning it back on, so both browsers are in compliance.
您可以在这里尝试:
var start = () => navigator.mediaDevices.getUserMedia({ video: true })
.then(stream => video.srcObject = stream)
.catch(e => log(e.name));
toggle.onclick = () => {
var track = video.srcObject && video.srcObject.getVideoTracks()[0];
if (!track) return;
toggle.innerHTML = (track.enabled = !track.enabled) ? "Disable" : "Enable";
}
var log = msg => div.innerHTML += "<p>" + msg + "</p>";
<video id="video" height="120" width="160" autoplay></video><br>
<button onclick="start()">Start!</button>
<button id="toggle">Disable</button><div id="div"></div>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
注意:在Chrome中,使用 https://jsfiddle.net/jib1/b6tyjm4s/代替(getUserMedia +代码段!=
Note: In Chrome use https://jsfiddle.net/jib1/b6tyjm4s/ instead (getUserMedia + snippets != <3).
关于原因,规范还说:
这可以从摄像头灯 以及浏览器内摄像头&麦克风实时指示器 .对于非永久权限,这两种浏览器均可以确保用户在摄像头指示灯熄灭时终止对网站的访问.在站点临时禁用流媒体时关闭电灯会破坏此保证.浏览器内指示器可能会支持此问题.
This is observable from the camera light as well as in-browser camera & microphone live indicators. For non-persistent permissions, both browsers guarantee users that a site's access ends when the camera light goes off. Turning off the light while a site temporarily disables a stream would break this guarantee. In-browser indicators may buttress this problem.
在Chrome中,我不得不推测何时使用 https
,但是至少对于Firefox(默认情况下,权限授予是非持久性的)而言,这就是原因.
I'd have to speculate when it comes to https
in Chrome, but at least for Firefox, where permission grants are non-persistent by default, this is why.
这篇关于为什么当音频和视频的MediaStreamTracks启用参数都设置为false时,为什么“广播"?指示灯一直亮着?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!