I have added this piece of code in my project
if (navigator.mediaDevices === undefined) {
navigator.mediaDevices = {};
}
if (navigator.mediaDevices.getUserMedia === undefined) {
navigator.mediaDevices.getUserMedia = function (constraints) {
var getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia
);
if (!getUserMedia) {
return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
}
return new Promise(function (resolve, reject) {
getUserMedia.call(navigator, constraints, resolve, reject);
});
};
}
Then I'm trying to access a video stream using getUserMedia
navigator.mediaDevices.getUserMedia({
video: true,
audio: false
}).then(stream => {
// do stuff
}).catch(error => {
console.log(error.name + + error.message);
});
When I test this in my emulators it works on android versions 5 and up, however when I run it on an actual device I get this error
NotReadableError Could not start source
I have added the cordova-plugin-media-capture
plugin to make sure my app will request the appropriate permissions, however I don't want to use the plugin I'd rather use the getUserMedia
API.
So far my researches show that the reason for this error is that some other app is already using the camera but that's not the case, I even went a step further and restarted the device, then opened my app, making sure there are no other running apps and I still got the error.
Has anyone had this issue?