Skip to content

Commit

Permalink
Merge pull request #777 from 549393092/patch-1
Browse files Browse the repository at this point in the history
Bugfix: it's not working when switch camera from front to back
  • Loading branch information
axxel committed Apr 29, 2024
2 parents 9d3b765 + dd6eba1 commit 3f8de98
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wrappers/wasm/demo_cam_reader.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h2>zxing-cpp/wasm live demo</h2>

Camera:
<select id="cameraSelector">
<option value="front">Front Camera</option>
<option value="back">Back Camera</option>
<option value="user">Front Camera</option>
<option value="environment">Back Camera</option>
</select>
&nbsp;&nbsp;

Expand Down Expand Up @@ -131,6 +131,9 @@ <h2>zxing-cpp/wasm live demo</h2>
};

const updateVideoStream = function (deviceId) {
// To ensure the camera switch, it is advisable to free up the media resources
if (video.srcObject) video.srcObject.getTracks().forEach(track => track.stop());

navigator.mediaDevices
.getUserMedia({ video: { facingMode: deviceId }, audio: false })
.then(function (stream) {
Expand Down

0 comments on commit 3f8de98

Please sign in to comment.