-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera-test.html
More file actions
90 lines (80 loc) · 2.7 KB
/
camera-test.html
File metadata and controls
90 lines (80 loc) · 2.7 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
<!DOCTYPE html>
<html>
<head>
<title>Camera Test</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background: #f0f0f0;
}
button {
padding: 15px 30px;
font-size: 18px;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 10px;
}
button:hover { background: #45a049; }
video {
border: 3px solid #333;
margin: 20px;
max-width: 400px;
}
.status {
padding: 10px;
margin: 10px;
border-radius: 5px;
font-weight: bold;
}
.success { background: #d4edda; color: #155724; }
.error { background: #f8d7da; color: #721c24; }
</style>
</head>
<body>
<h1>🎥 Camera Test Page</h1>
<p>This tests camera access without the extension</p>
<button onclick="testCamera()">Test Camera Access</button>
<button onclick="stopCamera()">Stop Camera</button>
<div id="status"></div>
<video id="video" autoplay muted style="display: none;"></video>
<script>
let stream = null;
function showStatus(message, isError = false) {
const status = document.getElementById('status');
status.textContent = message;
status.className = 'status ' + (isError ? 'error' : 'success');
}
async function testCamera() {
showStatus('Requesting camera access...');
try {
stream = await navigator.mediaDevices.getUserMedia({
video: {
width: { ideal: 640 },
height: { ideal: 480 }
}
});
const video = document.getElementById('video');
video.srcObject = stream;
video.style.display = 'block';
showStatus('✅ Camera access granted! Video should appear above.');
} catch (error) {
showStatus(`❌ Camera failed: ${error.name} - ${error.message}`, true);
console.error('Camera error:', error);
}
}
function stopCamera() {
if (stream) {
stream.getTracks().forEach(track => track.stop());
stream = null;
document.getElementById('video').style.display = 'none';
showStatus('Camera stopped');
}
}
</script>
</body>
</html>