Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
jcstein authored Sep 12, 2024
1 parent 2ee5b6f commit 1a34edd
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
width: 100%;
height: 100%;
object-fit: cover;
background-color: #000;
}
#camera video.mirrored {
transform: scaleX(-1);
Expand All @@ -49,18 +48,6 @@
font-size: 16px;
display: none;
}
#loadingIndicator {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
color: white;
background-color: rgba(0,0,0,0.7);
padding: 20px;
border-radius: 10px;
display: none;
}
@media (max-width: 768px) {
.container {
flex-direction: column;
Expand All @@ -73,7 +60,6 @@
<div id="camera">
<video autoplay playsinline></video>
<button id="switchCamera">Switch Camera</button>
<div id="loadingIndicator">Loading camera...</div>
</div>
<div id="lumina">
<iframe src="https://lumina.rs" allow="camera; microphone; fullscreen; display-capture; autoplay" sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"></iframe>
Expand All @@ -82,7 +68,6 @@
<script>
const video = document.querySelector('video');
const switchButton = document.getElementById('switchCamera');
const loadingIndicator = document.getElementById('loadingIndicator');
let currentStream = null;
let isUsingFrontCamera = true;
let hasMutipleCameras = false;
Expand All @@ -97,7 +82,6 @@
}

async function startVideo(useFrontCamera = true) {
loadingIndicator.style.display = 'block';
const facingMode = useFrontCamera ? 'user' : 'environment';
const constraints = {
video: { facingMode: facingMode }
Expand All @@ -112,15 +96,9 @@
isUsingFrontCamera = useFrontCamera;
updateMirrorEffect();

await new Promise((resolve) => {
video.onloadedmetadata = () => {
video.play().then(resolve).catch(resolve);
};
});
await video.play();
} catch (error) {
console.error('Error accessing camera:', error);
} finally {
loadingIndicator.style.display = 'none';
}
}

Expand All @@ -136,7 +114,6 @@
try {
await startVideo();

// Check if we can switch to the back camera
const devices = await navigator.mediaDevices.enumerateDevices();
const videoDevices = devices.filter(device => device.kind === 'videoinput');

Expand All @@ -146,14 +123,11 @@
}
} catch (error) {
console.error('Error initializing:', error);
hasMutipleCameras = false;
switchButton.style.display = 'none';
}
}

initialize();

// Ensure camera stream stays active
document.addEventListener('visibilitychange', () => {
if (!document.hidden && currentStream && currentStream.active) {
video.srcObject = currentStream;
Expand Down

0 comments on commit 1a34edd

Please sign in to comment.