I'm having trouble understanding why my code is not working. I've read that Safari 11 should be compatible with getUserMedia APIs from iOS 11, but for some reason it's not functioning as expected. My aim is to capture a QR code in a live stream, but I seem to be stuck at this point:
Controller
function BarcodeReaderQRCtrl($scope) {
/* widget controller */
var c = this;
var constraints = { audio: true, video: { width: 640, height: 480 } };
c.startMedia = function() {
navigator.mediaDevices
.getUserMedia(constraints)
.then(function(mediaStream) {
var video = document.getElementById('idvideo');
video.srcObject = mediaStream;
video.onloadedmetadata = function(e) {
video.play();
};
})
.catch(function(err) {
console.log(err.name + ': ' + err.message);
});
};
}
HTML
<div>
<a class="btn btn-default" href="#" role="button" ng-click="c.startMedia()">Start</a>
<div>
<video id="idvideo"></video>
</div>
</div>
Does anyone have any suggestions or solutions?