-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshareTheScreen.js
57 lines (46 loc) · 1.36 KB
/
shareTheScreen.js
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
var videoContainerSizes = {
sm: {
height: 320,
width: 480,
},
lg: {
height: 720,
width: 1080,
},
};
$("#share-screen").click(async () => {
await join();
$("#resize-video-container").attr("disabled", false);
});
$("#resize-video-container").click(() => {
const videoContainer = $(`#video-player-container`);
const sizeVariant = videoContainer.attr("data-size-variant");
if (sizeVariant === "sm") {
const sizes = videoContainerSizes["lg"];
videoContainer.css("width", sizes.width);
videoContainer.css("height", sizes.height);
videoContainer.attr("data-size-variant", "lg");
} else {
const sizes = videoContainerSizes["sm"];
videoContainer.css("width", sizes.width);
videoContainer.css("height", sizes.height);
videoContainer.attr("data-size-variant", "sm");
}
});
$("#replace-url").click(function () {
const browserUrl = new URL(window.location.toString());
if (browserUrl.searchParams.has("test-param")) {
browserUrl.searchParams.delete("test-param");
} else {
browserUrl.searchParams.append("test-param", Date.now().toString());
}
window.history.replaceState(null, "", browserUrl);
})
async function join() {
const captureStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: false,
});
const [video] = $("#video-player");
video.srcObject = captureStream;
}