-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
227 lines (202 loc) · 7.54 KB
/
index.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Screen Recorder</title>
<link rel="manifest" href="manifest.json">
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #282c34 0%, #3b3f4c 100%);
color: white;
margin: 0;
overflow: hidden;
position: relative;
}
.background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
z-index: -1;
}
.background svg {
position: absolute;
width: 500px;
height: 500px;
opacity: 0.1;
}
.background svg:nth-child(1) {
top: 10%;
left: 10%;
animation: float 6s ease-in-out infinite;
}
.background svg:nth-child(2) {
top: 50%;
left: 70%;
animation: float 8s ease-in-out infinite;
}
.background svg:nth-child(3) {
top: 80%;
left: 20%;
animation: float 5s ease-in-out infinite;
}
@keyframes float {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
.container {
text-align: center;
background-color: rgba(255, 255, 255, 0.1);
padding: 30px;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
max-width: 600px;
margin: 20px;
z-index: 1;
}
h1 {
font-size: 3em;
margin-bottom: 20px;
color: #61dafb;
}
button {
background-color: #61dafb;
color: #282c34;
border: none;
padding: 15px 30px;
font-size: 1.2em;
cursor: pointer;
margin: 10px;
border-radius: 5px;
transition: background-color 0.3s, transform 0.3s;
}
button:hover {
background-color: #4dabd4;
transform: scale(1.05);
}
video {
display: block;
margin: 20px auto;
width: 80%;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.checkbox-container {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
input[type="checkbox"] {
margin-right: 10px;
transform: scale(1.5);
}
label {
font-size: 1.2em;
color: #61dafb;
}
@media (max-width: 600px) {
h1 {
font-size: 2.5em;
}
button {
padding: 12px 24px;
font-size: 1em;
}
video {
width: 100%;
}
label {
font-size: 1em;
}
}
</style>
</head>
<body>
<div class="background">
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<path fill="#61dafb" d="M39.5,-47.8C52.4,-36.4,63.6,-23.1,65.7,-8.3C67.9,6.5,61.2,22.7,51.6,32.5C42,42.3,29.5,45.8,17.8,46.7C6,47.5,-5.9,45.8,-16.2,42.3C-26.6,38.8,-35.4,33.5,-39.8,25.9C-44.1,18.2,-44,8.1,-45.8,-3.6C-47.6,-15.3,-51.2,-30.7,-45.5,-42.8C-39.8,-54.8,-24.9,-63.6,-8.6,-62.4C7.7,-61.2,15.4,-50.2,39.5,-47.8Z" transform="translate(100 100)" />
</svg>
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<path fill="#61dafb" d="M39.5,-47.8C52.4,-36.4,63.6,-23.1,65.7,-8.3C67.9,6.5,61.2,22.7,51.6,32.5C42,42.3,29.5,45.8,17.8,46.7C6,47.5,-5.9,45.8,-16.2,42.3C-26.6,38.8,-35.4,33.5,-39.8,25.9C-44.1,18.2,-44,8.1,-45.8,-3.6C-47.6,-15.3,-51.2,-30.7,-45.5,-42.8C-39.8,-54.8,-24.9,-63.6,-8.6,-62.4C7.7,-61.2,15.4,-50.2,39.5,-47.8Z" transform="translate(100 100)" />
</svg>
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<path fill="#61dafb" d="M39.5,-47.8C52.4,-36.4,63.6,-23.1,65.7,-8.3C67.9,6.5,61.2,22.7,51.6,32.5C42,42.3,29.5,45.8,17.8,46.7C6,47.5,-5.9,45.8,-16.2,42.3C-26.6,38.8,-35.4,33.5,-39.8,25.9C-44.1,18.2,-44,8.1,-45.8,-3.6C-47.6,-15.3,-51.2,-30.7,-45.5,-42.8C-39.8,-54.8,-24.9,-63.6,-8.6,-62.4C7.7,-61.2,15.4,-50.2,39.5,-47.8Z" transform="translate(100 100)" />
</svg>
</div>
<div class="container">
<h1>Screen Recorder</h1>
<div class="checkbox-container">
<input type="checkbox" id="audioCheckbox">
<label for="audioCheckbox">Record Audio</label>
</div>
<button id="startBtn">Start Recording</button>
<button id="stopBtn" disabled>Stop Recording</button>
<video id="video" controls></video>
</div>
<script>
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const video = document.getElementById('video');
const audioCheckbox = document.getElementById('audioCheckbox');
let mediaRecorder;
let chunks = [];
startBtn.onclick = async () => {
try {
const displayStream = await navigator.mediaDevices.getDisplayMedia({ video: true });
let combinedStream = displayStream;
if (audioCheckbox.checked) {
const audioStream = await navigator.mediaDevices.getUserMedia({ audio: true });
combinedStream = new MediaStream([...displayStream.getTracks(), ...audioStream.getTracks()]);
}
mediaRecorder = new MediaRecorder(combinedStream);
mediaRecorder.ondataavailable = e => chunks.push(e.data);
mediaRecorder.onstop = e => {
const blob = new Blob(chunks, { type: 'video/mp4' });
chunks = [];
const videoURL = URL.createObjectURL(blob);
video.src = videoURL;
const a = document.createElement('a');
a.href = videoURL;
a.download = `screen_recording_${new Date().toISOString().replace(/:|\./g, '-')}.mp4`;
a.click();
};
mediaRecorder.start();
startBtn.disabled = true;
stopBtn.disabled = false;
} catch (error) {
console.error('Error starting recording:', error);
}
};
stopBtn.onclick = () => {
mediaRecorder.stop();
startBtn.disabled = false;
stopBtn.disabled = true;
};
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/ScreenRecorder/sw.js')
.then(registration => {
console.log('Service Worker registered:', registration);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
});
}
</script>
</body>
</html>