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 c5b9249 commit 802e7cd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
border-radius: 5px;
cursor: pointer;
font-size: 16px;
display: none; /* Initially hidden */
}
@media (max-width: 768px) {
.container {
Expand All @@ -62,7 +63,6 @@
<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>
</div>
</div>

<script>
const video = document.querySelector('video');
const switchButton = document.getElementById('switchCamera');
Expand All @@ -77,7 +77,6 @@
const constraints = {
video: deviceId ? { deviceId: { exact: deviceId } } : true
};

try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
video.srcObject = stream;
Expand All @@ -91,7 +90,6 @@
const devices = await getVideoDevices();
const currentDevice = currentStreamTrack?.getSettings().deviceId;
const nextDevice = devices.find(d => d.deviceId !== currentDevice);

if (nextDevice) {
if (currentStreamTrack) {
currentStreamTrack.stop();
Expand All @@ -105,7 +103,7 @@
// Initial camera start
startVideo();

// Check if the device has multiple cameras
// Check if the device has multiple cameras and show/hide button accordingly
getVideoDevices().then(devices => {
if (devices.length > 1) {
switchButton.style.display = 'block';
Expand Down

0 comments on commit 802e7cd

Please sign in to comment.