Im currently trying to develop an android application with cordova. I want to get the stream from the camera. On Windows I achieved that like this:
if (!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia)) {
alert("NO CAMERA SUPPORTED");
return;
}
var video = document.querySelector("#capture-video video");
navigator.mediaDevices.getUserMedia({video: true}).then((stream) => {
video.srcObject = stream;
});
which is working fine. However, on Android I always get a NonReadableError when trying to alert the stream ID with navigator.mediaDevices.getUserMedia({video:true}).then(stream => alert(stream.id); and the video stays blank. My config.xml is looking like this:
<?xml version='1.0' encoding="'utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']">
<activity android:name="MainActivity" android:windowSoftInputMode="adjustPan" />
</edit-config>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</config-file>
<icon src="www/img/logo2.png"/>
<allow-intent href="market:*" />
<preference name="android-manifest/application/activity/@android:windowSoftInputMode" value="adjustPan" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
I also tried different cordova plugins like cordova-media-capture and others but they all opened the default camera which is not what i want. Does anybody have an idea how I could achieve it to let the user take a photo but not using the default camera application?