Firefox 22 mozGetUserMedia使用“屏幕”作为设备源 [英] Firefox 22 mozGetUserMedia using 'screen' as device source
问题描述
Chrome 26+技术确实存在,它为屏幕捕获提供了实验支持(使用屏幕作为设备源)。用于实现此目的的代码(代码片段)是:
$ p $ //选择任何支持的getUserMedia函数
navigator.getMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
//如果不支持getUserMedia,则不执行
if(!navigator.getMedia)return;
//用户媒体请求
navigator.getMedia(
{
video:{
mandatory:{
// request'screen '作为源媒体
chromeMediaSource:'screen'
}
}
},
//成功
函数(localMediaStream)
{
//处理本地媒体流...
},
//失败
函数(错误)
{
//错误处理
});
查看W3C文档,对象 MediaSourceConstraints,MediaTrackConstraints,MediaTrackConstraintsSet
还没有被标准化。这可能仅仅是因为这个功能出现在Firefox生产环境中,这个API太雾了。这只是很好的知道当前的支持状态。
解决方案
现在可以在Firefox中使用,但是由于安全问题,支持隐藏在一些偏好背后。特别是 对Mozilla错误报告的评论说明了其中的一些关注: 现在我们重新设计了 尽管在发行版频道中,默认情况下, 在允许列表中,您可以通过使用 Mozilla托管一个 getUserMedia测试页,由Firefox Nightly和Firefox Developer Edition列出的域名。如果你使用这两个版本的Firefox,你可以看到它的实际应用。或者,您可以将域添加到 There have been some buzz in the air for the WebRTC support in Firefox 22. This is for someone who's in the know about Firefox development: Are there any support in Firefox for desktop screen capture todate? The technology does exist for Chrome 26+, which provides experimental support for screen capturing (using 'screen' as device source); the code (snippet) for making this happen is: Looking at W3C docs, the objects This is now possible in Firefox, however due to security concerns, support is hidden behind some preferences. Specifically the This comment on a Mozilla bug report illustrates some of those concerns: Now that we've redesigned Even with user opt-in, I'd worry about situations like "user loads app page A in one tab and app page B in another tab, page B asks for permission to screen-share page A which looks fine, user accepts, then app swaps an Though If your domain is on the allowed list, you can use it by using the following keys in the Mozilla hosts a getUserMedia Test Page, on a domain that is white-listed by Firefox Nightly and Firefox Developer Edition. If you use either of these versions of Firefox, you can see it in action. Alternately you could add the domain to the whitelist under 这篇关于Firefox 22 mozGetUserMedia使用“屏幕”作为设备源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! about:config 中
media.getusermedia。*
偏好设置。
$ b
< input type =file>
不能在屏幕上绘制完整的路径,事情会更好。我们仍然在绘制交叉图像和< iframe>
s之类的问题上存在问题。< iframe>
或者其他任何东西进入页面A并抓取内容。
media.getusermedia.screensharing.enabled
当前 true
在> media.getusermedia.screensharing.allowed_domains
下列入白名单的网域实际上允许使用它。
视频
属性中的以下键来使用它。
video:{
mozMediaSource:screen,
mediaSource:screen
}
about:config
下的白名单中,然后在发布版和测试版渠道中使用它。 // select any supported getUserMedia function
navigator.getMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
// if getUserMedia is not supported, do nothing
if( !navigator.getMedia ) return;
// request for user media
navigator.getMedia(
{
video : {
mandatory : {
// request 'screen' as a source media
chromeMediaSource : 'screen'
}
}
},
// success
function( localMediaStream )
{
// process local media stream...
},
// failure
function( error )
{
// error handling
});
MediaSourceConstraints, MediaTrackConstraints, MediaTrackConstraintsSet
have not yet been standardized. It might simply be that the API is all too foggy for this feature to appear in Firefox production. It would just be good to know the current state of support.media.getusermedia.*
preferences under about:config
.
<input type="file">
to not draw the full path on the screen, things are better. We still have problems with things like drawing cross-origin images and <iframe>
s.<iframe>
of FB or gmail or whatever into page A and grabs the contents.media.getusermedia.screensharing.enabled
is currently true
by default in the release channel, only those domains whitelisted under media.getusermedia.screensharing.allowed_domains
are actually allowed to use it.video
property.video: {
mozMediaSource: "screen",
mediaSource: "screen"
}
about:config
and use it in the release and beta channels.