File size: 1,716 Bytes
b27cb15
 
d6fb0af
eb315e4
 
099d93c
eb315e4
 
099d93c
eb315e4
 
 
d6fb0af
 
 
b27cb15
099d93c
 
d6fb0af
099d93c
 
 
 
 
 
 
 
 
693b035
d6fb0af
693b035
099d93c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b27cb15
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
// scripts/video.js

async function startRecording() {
    if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
        try {
            const stream = await navigator.mediaDevices.getDisplayMedia({ video: true });
            alert("Screen access granted! Recording can now begin.");
        } catch (error) {
            alert(`Could not start recording. Error: ${error.message}`);
        }
    } else {
        alert("Sorry, your browser or current viewing environment does not support screen recording.");
    }
}

export function initVideo() {
    const productionButton = document.getElementById('production-button');
    const productionPanel = document.getElementById('production-panel');
    const startBtn = document.getElementById('start-recording');
    const tabs = document.querySelectorAll('.tab');
    const sections = document.querySelectorAll('.production-panel > div[id$="-section"]');

    if (productionButton) {
        productionButton.addEventListener('click', () => {
            productionPanel.classList.toggle('open');
        });
    }

    if (startBtn) {
        startBtn.addEventListener('click', startRecording);
    }

    tabs.forEach(tab => {
        tab.addEventListener('click', () => {
            tabs.forEach(t => t.classList.replace('active', 'inactive'));
            tab.classList.replace('inactive', 'active');

            const targetSectionId = tab.dataset.tab;
            sections.forEach(section => {
                if (section.id === targetSectionId) {
                    section.classList.remove('hidden');
                } else {
                    section.classList.add('hidden');
                }
            });
        });
    });
}