Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e4705dc2
提交
e4705dc2
authored
2月 17, 2015
作者:
Anthony Minessale
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7509: add file to demo
上级
2c4c2587
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
99 行增加
和
0 行删除
+99
-0
getScreenId.js
html5/verto/video_demo/js/getScreenId.js
+99
-0
没有找到文件。
html5/verto/video_demo/js/getScreenId.js
0 → 100644
浏览文件 @
e4705dc2
// Last time updated at Sep 07, 2014, 08:32:23
// Latest file can be found here: https://cdn.webrtc-experiment.com/getScreenId.js
// Muaz Khan - www.MuazKhan.com
// MIT License - www.WebRTC-Experiment.com/licence
// Documentation - https://github.com/muaz-khan/WebRTC-Experiment/tree/master/getScreenId.js
// ______________
// getScreenId.js
/*
getScreenId(function (error, sourceId, screen_constraints) {
// error == null || 'permission-denied' || 'not-installed' || 'installed-disabled' || 'not-chrome'
// sourceId == null || 'string' || 'firefox'
if(sourceId == 'firefox') {
navigator.mozGetUserMedia(screen_constraints, onSuccess, onFailure);
}
else navigator.webkitGetUserMedia(screen_constraints, onSuccess, onFailure);
});
*/
(
function
()
{
window
.
getScreenId
=
function
(
callback
)
{
// for Firefox:
// sourceId == 'firefox'
// screen_constraints = {...}
if
(
!!
navigator
.
mozGetUserMedia
)
{
callback
(
null
,
'firefox'
,
{
video
:
{
mozMediaSource
:
'window'
,
mediaSource
:
'window'
}
});
return
;
}
postMessage
();
window
.
addEventListener
(
'message'
,
onIFrameCallback
);
function
onIFrameCallback
(
event
)
{
if
(
!
event
.
data
)
return
;
if
(
event
.
data
.
chromeMediaSourceId
)
{
if
(
event
.
data
.
chromeMediaSourceId
===
'PermissionDeniedError'
)
{
callback
(
'permission-denied'
);
}
else
callback
(
null
,
event
.
data
.
chromeMediaSourceId
,
getScreenConstraints
(
null
,
event
.
data
.
chromeMediaSourceId
));
}
if
(
event
.
data
.
chromeExtensionStatus
)
{
callback
(
event
.
data
.
chromeExtensionStatus
,
null
,
getScreenConstraints
(
event
.
data
.
chromeExtensionStatus
));
}
// this event listener is no more needed
window
.
removeEventListener
(
'message'
,
onIFrameCallback
);
}
};
function
getScreenConstraints
(
error
,
sourceId
)
{
var
screen_constraints
=
{
audio
:
false
,
video
:
{
mandatory
:
{
chromeMediaSource
:
error
?
'screen'
:
'desktop'
,
maxWidth
:
window
.
screen
.
width
>
1920
?
window
.
screen
.
width
:
1920
,
maxHeight
:
window
.
screen
.
height
>
1080
?
window
.
screen
.
height
:
1080
},
optional
:
[]
}
};
if
(
sourceId
)
{
screen_constraints
.
video
.
mandatory
.
chromeMediaSourceId
=
sourceId
;
}
return
screen_constraints
;
}
function
postMessage
()
{
if
(
!
iframe
.
isLoaded
)
{
setTimeout
(
postMessage
,
100
);
return
;
}
iframe
.
contentWindow
.
postMessage
({
captureSourceId
:
true
},
'*'
);
}
var
iframe
=
document
.
createElement
(
'iframe'
);
iframe
.
onload
=
function
()
{
iframe
.
isLoaded
=
true
;
};
iframe
.
src
=
'https://www.webrtc-experiment.com/getSourceId/'
;
iframe
.
style
.
display
=
'none'
;
(
document
.
body
||
document
.
documentElement
).
appendChild
(
iframe
);
})();
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论