Spaces:
Running
Running
Update scripts/video.js
Browse files- scripts/video.js +29 -11
scripts/video.js
CHANGED
@@ -1,30 +1,48 @@
|
|
1 |
// scripts/video.js
|
2 |
|
3 |
async function startRecording() {
|
4 |
-
// First, check if the browser supports the getDisplayMedia API at all.
|
5 |
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
6 |
-
// If it exists, try to use it.
|
7 |
try {
|
8 |
-
const stream = await navigator.mediaDevices.getDisplayMedia({
|
9 |
-
video: true
|
10 |
-
});
|
11 |
-
// If the user gives permission, this code will run.
|
12 |
alert("Screen access granted! Recording can now begin.");
|
13 |
-
// (The actual logic to handle the video stream would go here)
|
14 |
-
|
15 |
} catch (error) {
|
16 |
-
|
17 |
-
alert(`Screen recording was cancelled or denied. Error: ${error.message}`);
|
18 |
}
|
19 |
} else {
|
20 |
-
// If the API doesn't exist, inform the user gracefully.
|
21 |
alert("Sorry, your browser or current viewing environment does not support screen recording.");
|
22 |
}
|
23 |
}
|
24 |
|
25 |
export function initVideo() {
|
|
|
|
|
26 |
const startBtn = document.getElementById('start-recording');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
if (startBtn) {
|
28 |
startBtn.addEventListener('click', startRecording);
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
|
|
1 |
// scripts/video.js
|
2 |
|
3 |
async function startRecording() {
|
|
|
4 |
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
|
5 |
try {
|
6 |
+
const stream = await navigator.mediaDevices.getDisplayMedia({ video: true });
|
|
|
|
|
|
|
7 |
alert("Screen access granted! Recording can now begin.");
|
|
|
|
|
8 |
} catch (error) {
|
9 |
+
alert(`Could not start recording. Error: ${error.message}`);
|
|
|
10 |
}
|
11 |
} else {
|
|
|
12 |
alert("Sorry, your browser or current viewing environment does not support screen recording.");
|
13 |
}
|
14 |
}
|
15 |
|
16 |
export function initVideo() {
|
17 |
+
const productionButton = document.getElementById('production-button');
|
18 |
+
const productionPanel = document.getElementById('production-panel');
|
19 |
const startBtn = document.getElementById('start-recording');
|
20 |
+
const tabs = document.querySelectorAll('.tab');
|
21 |
+
const sections = document.querySelectorAll('.production-panel > div[id$="-section"]');
|
22 |
+
|
23 |
+
if (productionButton) {
|
24 |
+
productionButton.addEventListener('click', () => {
|
25 |
+
productionPanel.classList.toggle('open');
|
26 |
+
});
|
27 |
+
}
|
28 |
+
|
29 |
if (startBtn) {
|
30 |
startBtn.addEventListener('click', startRecording);
|
31 |
}
|
32 |
+
|
33 |
+
tabs.forEach(tab => {
|
34 |
+
tab.addEventListener('click', () => {
|
35 |
+
tabs.forEach(t => t.classList.replace('active', 'inactive'));
|
36 |
+
tab.classList.replace('inactive', 'active');
|
37 |
+
|
38 |
+
const targetSectionId = tab.dataset.tab;
|
39 |
+
sections.forEach(section => {
|
40 |
+
if (section.id === targetSectionId) {
|
41 |
+
section.classList.remove('hidden');
|
42 |
+
} else {
|
43 |
+
section.classList.add('hidden');
|
44 |
+
}
|
45 |
+
});
|
46 |
+
});
|
47 |
+
});
|
48 |
}
|