-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
95 lines (72 loc) · 1.8 KB
/
test.html
File metadata and controls
95 lines (72 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!doctype html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title> dotEngine </title>
<style type="text/css">
.room {
cursor: pointer;
}
div.select {
display: inline-block;
margin: 0 0 1em 0;
}
</style>
<script type='text/javascript'>
let screen_constraints = {
mandatory: {
chromeMediaSource: 'desktop',
maxWidth: 1280,
maxHeight: 720
},
optional: []
};
let extensionExist;
window.addEventListener('message', function(event) {
console.log(event)
onMessageCallback(event.data);
});
function onMessageCallback(data) {
// "cancel" button is clicked
if (data == 'PermissionDeniedError') {
alert('PermissionDeniedError');
}
// extension notified his presence
if (data == 'extension-loaded') {
alert('extension-loaded')
}
// extension shared temp sourceId
if(data.sourceId){
screen_constraints.mandatory.chromeMediaSourceId = data.sourceId;
getUserMedia(screen_constraints)
}
}
function getUserMedia(constraints){
navigator.getUserMedia({video:constraints}, function (stream) {
var video = document.querySelector('video');
video.src = URL.createObjectURL(stream);
video.play();
console.log('video play')
}, function (error) {
console.error(error);
});
}
function getSourceId() {
window.postMessage('get-sourceId', '*')
}
function checkExtension() {
window.postMessage('are-you-there','*')
}
</script>
</head>
<body>
<video controls autoplay width="320" height="240"></video>
<br/>
<button onclick="getSourceId();">
getSource
</button>
<button onclick="checkExtension();">
checkExtension()
</button>
</body>
</html>