-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
149 lines (144 loc) · 3.99 KB
/
index.html
File metadata and controls
149 lines (144 loc) · 3.99 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link
rel="icon"
href="https://cdn.glitch.com/e6f60565-f728-4029-9d6b-e3a05dbf80fb%2Fanother-screen.svg?v=1611520540818"
/>
<link rel="manifest" href="manifest.webmanifest" />
<title>another-screen</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
background: black;
color: #8b8685;
}
#o {
position: absolute;
top: 50%; left: 0; right: 0; text-align: center;
transform: translateY(-50%);
font-size: 24px;
line-height: 1.5;
}
button {
font-size: 10vw;
background: linear-gradient(to bottom, #353433, #252423);
border: 2px solid #454443;
color: #d7fc70;
padding: 0.25em 0.5em;
border-radius: 0.25em;
cursor: pointer;
}
#v {
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
box-sizing: border-box;
background: black;
cursor: pointer;
}
#menu {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(20, 20, 20, 0.95);
border: 2px solid #454443;
border-radius: 8px;
padding: 20px;
display: none;
z-index: 1000;
min-width: 200px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
#menu.show {
display: block;
}
.menu-option {
background: linear-gradient(to bottom, #353433, #252423);
border: 2px solid #454443;
color: #d7fc70;
padding: 12px 16px;
margin: 8px 0;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
width: 100%;
text-align: left;
transition: all 0.2s;
}
.menu-option:hover {
background: linear-gradient(to bottom, #454443, #353433);
border-color: #d7fc70;
}
</style>
</head>
<body>
<script>
const params = new URLSearchParams(location.search)
async function start(b) {
try {
let video = true
if (params.get('r')) {
video = {
frameRate: { ideal: +params.get('r') }
}
}
const s = await navigator.mediaDevices.getDisplayMedia({ video })
v.srcObject = s
v.play()
b.hidden = true
} catch (e) {
alert(e)
}
}
function hideMenu() {
document.getElementById('menu').classList.remove('show')
}
function showMenu(e) {
e.stopPropagation()
document.getElementById('menu').classList.toggle('show')
}
async function goFullscreen() {
try {
await v.requestFullscreen()
hideMenu()
} catch (e) {
alert('Fullscreen failed: ' + e.message)
}
}
async function goPictureInPicture() {
try {
if (document.pictureInPictureElement) {
await document.exitPictureInPicture()
} else {
await v.requestPictureInPicture()
}
hideMenu()
} catch (e) {
alert('Picture-in-Picture failed: ' + e.message)
}
}
document.addEventListener('click', hideMenu)
</script>
<video id="v" onclick="showMenu(event)"></video>
<div id="menu">
<button class="menu-option" onclick="goFullscreen()">⛶ Fullscreen</button>
<button class="menu-option" onclick="goPictureInPicture()">🖼 Picture-in-Picture</button>
</div>
<div id="o">
<button onclick="start(this.parentNode)">Select screen</button>
<p>
<strong>another-screen</strong> is a web application that lets you mirror a screen locally.<br />
Useful when presenting and demoing but the projector is behind you.
</p>
</div>
<script>
if (navigator.serviceWorker && !navigator.serviceWorker.controller) {
navigator.serviceWorker.register("/serviceworker.js");
}
</script>
</body>
</html>