firefox 指定当前 window 以使用 getUserMedia 进行流式传输
firefox specify current window to stream with getUserMedia
在 firefox 中,我可以使用
请求 window 的视频流
navigator.mediaDevices.getUserMedia({
video: {
mediaSource: 'window',
},
})
这会产生如下对话框:
我只关心现在的window。有没有办法在我对 getUserMedia
的调用中指定我只想要当前选项卡(或 window)?
我不这么认为...
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, instead of "window"
. While the specs are not really clear as to what it is exactly ("a browser display surface, or single browser window"), I guess it will be closer to what you want than "window"
, and someone even asked 2 days ago for a "tab"
constraint,我们甚至可以希望有一个“当前选项卡”约束吗? 这可能需要有人在 w3c github 的页面上提出问题。
在 firefox 中,我可以使用
请求 window 的视频流navigator.mediaDevices.getUserMedia({
video: {
mediaSource: 'window',
},
})
这会产生如下对话框:
我只关心现在的window。有没有办法在我对 getUserMedia
的调用中指定我只想要当前选项卡(或 window)?
我不这么认为...
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, instead of "window"
. While the specs are not really clear as to what it is exactly ("a browser display surface, or single browser window"), I guess it will be closer to what you want than "window"
, and someone even asked 2 days ago for a "tab"
constraint,我们甚至可以希望有一个“当前选项卡”约束吗? 这可能需要有人在 w3c github 的页面上提出问题。