File size: 11,087 Bytes
95d2bc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Webcam Access</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .camera-container {
            position: relative;
            width: 100%;
            max-width: 640px;
            margin: 0 auto;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            background: linear-gradient(145deg, #f0f0f0, #ffffff);
        }
        
        .video-placeholder {
            width: 100%;
            aspect-ratio: 16/9;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            color: #4b5563;
        }
        
        .video-element {
            width: 100%;
            height: auto;
            display: none;
            transform: scaleX(-1); /* Mirror effect */
        }
        
        .controls {
            position: absolute;
            bottom: 20px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: center;
            gap: 16px;
            z-index: 10;
        }
        
        .btn {
            padding: 12px 24px;
            border-radius: 50px;
            font-weight: 600;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }
        
        .btn-secondary {
            background: rgba(255, 255, 255, 0.9);
            color: #4b5563;
            border: 1px solid #e5e7eb;
        }
        
        .btn-secondary:hover {
            background: white;
            transform: translateY(-2px);
        }
        
        .permission-denied {
            display: none;
            text-align: center;
            padding: 20px;
            color: #ef4444;
            background-color: #fee2e2;
            border-radius: 8px;
            margin-top: 20px;
        }
        
        .loading {
            display: none;
            flex-direction: column;
            align-items: center;
            gap: 16px;
        }
        
        .spinner {
            width: 40px;
            height: 40px;
            border: 4px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-left-color: #764ba2;
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        .status {
            margin-top: 20px;
            padding: 10px;
            border-radius: 8px;
            text-align: center;
            display: none;
        }
        
        .success {
            background-color: #dcfce7;
            color: #166534;
        }
        
        .error {
            background-color: #fee2e2;
            color: #991b1b;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col items-center justify-center p-4">
    <div class="max-w-2xl w-full space-y-8">
        <div class="text-center">
            <h1 class="text-3xl font-bold text-gray-900 mb-2">Webcam Access</h1>
            <p class="text-gray-600">Click the button below to start your camera</p>
        </div>
        
        <div class="camera-container">
            <div class="video-placeholder" id="placeholder">
                <div class="text-center p-6">
                    <i class="fas fa-camera text-4xl mb-4 text-gray-400"></i>
                    <p class="text-lg font-medium">Camera feed will appear here</p>
                    <p class="text-sm text-gray-500 mt-2">Click "Start Camera" to begin</p>
                </div>
            </div>
            
            <video id="video" class="video-element" autoplay playsinline></video>
            
            <div class="controls">
                <button id="startBtn" class="btn btn-primary">
                    <i class="fas fa-play"></i> Start Camera
                </button>
                <button id="stopBtn" class="btn btn-secondary" disabled>
                    <i class="fas fa-stop"></i> Stop
                </button>
            </div>
        </div>
        
        <div id="loading" class="loading">
            <div class="spinner"></div>
            <p>Accessing your camera...</p>
        </div>
        
        <div id="permissionDenied" class="permission-denied">
            <i class="fas fa-exclamation-triangle text-2xl mb-2"></i>
            <p>Camera access was denied. Please refresh and allow camera permissions.</p>
        </div>
        
        <div id="statusMessage" class="status">
            <!-- Status messages will appear here -->
        </div>
        
        <div class="mt-8 bg-white p-6 rounded-xl shadow-sm border border-gray-200">
            <h2 class="text-xl font-semibold mb-4 text-gray-800">Privacy Notice</h2>
            <p class="text-gray-600 mb-4">
                This application requires camera access to function properly. Your video feed is processed locally in your browser and is not stored or transmitted to any servers.
            </p>
            <div class="flex items-center text-sm text-gray-500">
                <i class="fas fa-lock mr-2"></i>
                <span>Your privacy is important to us. Camera access is used solely for this session.</span>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const video = document.getElementById('video');
            const startBtn = document.getElementById('startBtn');
            const stopBtn = document.getElementById('stopBtn');
            const placeholder = document.getElementById('placeholder');
            const loading = document.getElementById('loading');
            const permissionDenied = document.getElementById('permissionDenied');
            const statusMessage = document.getElementById('statusMessage');
            
            let stream = null;
            
            // Function to start the camera
            async function startCamera() {
                try {
                    // Show loading state
                    startBtn.disabled = true;
                    placeholder.style.display = 'none';
                    loading.style.display = 'flex';
                    permissionDenied.style.display = 'none';
                    
                    // Request camera access
                    stream = await navigator.mediaDevices.getUserMedia({
                        video: {
                            width: { ideal: 1280 },
                            height: { ideal: 720 },
                            facingMode: 'user'
                        },
                        audio: false
                    });
                    
                    // Display the video stream
                    video.srcObject = stream;
                    video.style.display = 'block';
                    
                    // Hide loading and show success
                    loading.style.display = 'none';
                    stopBtn.disabled = false;
                    
                    // Show status message
                    showStatus('Camera access granted!', 'success');
                    
                } catch (err) {
                    console.error('Error accessing camera:', err);
                    
                    // Show appropriate error message
                    loading.style.display = 'none';
                    startBtn.disabled = false;
                    
                    if (err.name === 'NotAllowedError') {
                        permissionDenied.style.display = 'block';
                        showStatus('Camera access was denied.', 'error');
                    } else if (err.name === 'NotFoundError') {
                        showStatus('No camera device found.', 'error');
                    } else {
                        showStatus('Error accessing camera: ' + err.message, 'error');
                    }
                    
                    // Show placeholder again
                    placeholder.style.display = 'flex';
                }
            }
            
            // Function to stop the camera
            function stopCamera() {
                if (stream) {
                    const tracks = stream.getTracks();
                    tracks.forEach(track => track.stop());
                    video.srcObject = null;
                    stream = null;
                    
                    // Reset UI
                    video.style.display = 'none';
                    placeholder.style.display = 'flex';
                    startBtn.disabled = false;
                    stopBtn.disabled = true;
                    
                    showStatus('Camera stopped.', 'success');
                }
            }
            
            // Function to show status messages
            function showStatus(message, type) {
                statusMessage.textContent = message;
                statusMessage.className = 'status ' + type;
                statusMessage.style.display = 'block';
                
                // Hide after 5 seconds
                setTimeout(() => {
                    statusMessage.style.display = 'none';
                }, 5000);
            }
            
            // Event listeners
            startBtn.addEventListener('click', startCamera);
            stopBtn.addEventListener('click', stopCamera);
            
            // Check if browser supports mediaDevices
            if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
                startBtn.disabled = true;
                showStatus('Your browser does not support camera access.', 'error');
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=rerisson2006/kks" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>