I've just found "say-cheese" JS to open phone cam in a webpage.
https://github.com/Kephson/html5qrcodereader
My project is to read QR Codes with a smartphones camera and enter the data into a input field on a website.
The JS library works just fine!
My problem is that the code only uses the default camera (front), and i want to use the rear camera also.
How can i implement this code:
https://github.com/samdutton/simpl/blob/gh-pages/getusermedia/sources/js/main.js
Into this code: https://github.com/Kephson/html5qrcodereader/blob/master/js/say-cheese.js
HTML SELECT
<!--SELECT CAMERA-->
<select id="videoSource">
<option selected>Default Camera</option>
</select>
Some random code from say-cheese.js
//Get Cameras?!
navigator.getUserMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia ||
false);
SayCheese = function SayCheese(element, options) {
this.snapshots = [],
this.video = null,
this.events = {},
this.stream = null,
this.options = {
videoSource: null,
snapshots: true,
audio: false,
width: 320
};
return navigator.getUserMedia({video: {
optional: [{
sourceId: this.options.videoSource
}]
Is it somewhere in the code above i should put something like:
function gotDevices(deviceInfos) {
for (var i = 0; i !== deviceInfos.length; ++i) {
var deviceInfo = deviceInfos[i];
var option = document.createElement('option');
option.value = deviceInfo.deviceId;
if (deviceInfo.kind === 'audioinput') {
option.text =
deviceInfo.label || 'microphone ' + (audioSelect.length + 1);
audioSelect.appendChild(option);
} else if (deviceInfo.kind === 'videoinput') {
option.text = deviceInfo.label || 'camera ' + (videoSelect.length + 1);
videoSelect.appendChild(option);
} else {
console.log('Found one other kind of source/device: ', deviceInfo);
}
}
}
As you can tell i do not know so much about JS.
I'm using Jquery to almost everything i need.