gpt4 book ai didi

javascript - firefox 指定当前窗口以使用 getUserMedia 进行流式传输

转载 作者:行者123 更新时间:2023-11-30 21:02:17 27 4
gpt4 key购买 nike

在 firefox 中,我可以请求一个窗口的视频流

navigator.mediaDevices.getUserMedia({
video: {
mediaSource: 'window',
},
})

这会产生一个像这样的对话框:

我只关心当前窗口。有没有办法在我对 getUserMedia 的调用中指定我只想要当前选项卡(或窗口)?

最佳答案

我不这么认为,不...

FF 在这里实现了什么还没有具体说明,但是 w3c 正在开发一个新的 API 来处理屏幕捕获:MediaDevices.getDisplayMedia .

虽然这不是 Firefox 确实实现的,但有一个 clear paragraph在这篇关于为什么 deviceId 不能也不会处理此类请求的论文中:

Each potential source of capture is treated by this API as a discrete media source. However, display capture sources MUST NOT be enumerated by enumerateDevices, since this would reveal too much information about the host system.

Display capture sources therefore cannot be selected with the deviceId constraint, since this would allow applications to influence selection; setting deviceId constraint can only cause the resulting MediaStreamTrack to become overconstrained.

因此,即使 FF 尚未实现此 API,我们仍然可以假设他们在当前实现中确实遵循相同的规则,原因相同。

然而,当这个 API 出现时,显然可以做的是使用 "browser" constraint , 而不是 "window"。虽然规范并不清楚它到底是什么(“一个浏览器显示表面,或单个浏览器窗口”),但我想它会比 “window”更接近你想要的",甚至有人在 2 天前询问了 "tab" constraint ,我们甚至可以希望有一个“当前选项卡”约束吗? 这可能需要有人在 w3c github 页面上提出问题。

关于javascript - firefox 指定当前窗口以使用 getUserMedia 进行流式传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47022259/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com