Skip to content

Commit

Permalink
docs: simple demo that renders camera capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
gruhn committed Dec 15, 2023
1 parent 504e46d commit 542d920
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/public/select-camera-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<ul></ul>
<br>
<video autoplay muted playsinline></video>
<h3>Capabilities:</h3>
<pre id="capabilities"></pre>

<script>
const listEl = document.querySelector("ul")
Expand All @@ -23,10 +25,11 @@
.map(({ label, deviceId }) => {
const el = document.createElement('li')

if (deviceId == currentDeviceId)
el.innerHTML = `<a href="#" onclick="selectCamera('${deviceId}')">${label}</a> [PREFERRED]`
else
if (deviceId == currentDeviceId) {
el.innerHTML = `<a href="#" onclick="selectCamera('${deviceId}')">${label}</a>`
} else {
el.innerHTML = `<a href="#" onclick="selectCamera('${deviceId}')">${label}</a>`
}

return el
})
Expand Down Expand Up @@ -65,6 +68,9 @@
videoTrack.getSettings().deviceId,
await navigator.mediaDevices.enumerateDevices()
)

const capEl = document.querySelector("#capabilities")
capEl.innerText = JSON.stringify(videoTrack.getCapabilities(), null, 2)
} catch (error) {
console.error(error)
}
Expand Down

0 comments on commit 542d920

Please sign in to comment.