Skip to content

Commit

Permalink
Merge pull request #265 from beaufortfrancois/fix-nits
Browse files Browse the repository at this point in the history
Fix nits in PTZ example
  • Loading branch information
riju committed Sep 30, 2020
2 parents da61286 + 9bbd57c commit d27d3a3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions index.bs
Expand Up @@ -897,16 +897,16 @@ A {{Point2D}} represents a location in a two dimensional space. The origin of co
<body>
<video autoplay></video>
<img>
<div hidden>
<input id="pan" name="pan" title="Pan" type="range" />
<div>
<input id="pan" title="Pan" type="range" disabled />
<label for="pan">Pan</label>
</div>
<div hidden>
<input id="tilt" name="tilt" title="Tilt" type="range" />
<div>
<input id="tilt" title="Tilt" type="range" disabled />
<label for="tilt">Tilt</label>
</div>
<div hidden>
<input id="zoom" name="zoom" title="Zoom" type="range" />
<div>
<input id="zoom" title="Zoom" type="range" disabled />
<label for="zoom">Zoom</label>
</div>
<script>
Expand All @@ -928,22 +928,23 @@ A {{Point2D}} represents a location in a two dimensional space. The origin of co

for (const ptz of ['pan', 'tilt', 'zoom']) {
// Check whether pan/tilt/zoom is available or not.
if (!capabilities[ptz]) continue;
if (!(ptz in settings)) continue;

// Map it to a slider element.
const input = document.querySelector(`input[name=${ptz}][type="range"]`);
const input = document.getElementById(ptz);
input.min = capabilities[ptz].min;
input.max = capabilities[ptz].max;
input.step = capabilities[ptz].step;
input.value = settings[ptz];
input.disabled = false;
input.oninput = async event => {
try {
// Warning: Chrome requires advanced constraints.
await track.applyConstraints({[ptz]: input.value});
} catch (err) {
console.error("applyConstraints() failed: ", err);
}
};
input.parentElement.hidden = false;
}
} catch (err) {
console.error(err);
Expand Down

0 comments on commit d27d3a3

Please sign in to comment.