Hi, i want to start the camera preview which is delivered throught the camera-preview plugin. This my code for the camera activation:
initCamera() {
this.FLASH_LIGHT_STATUS = false;
this.CAMERA_STATUS = false;
this.cameraPreview.startCamera(this.cameraOptions).then(() => {
console.info("Camera started.");
this.cameraPreview.hide().then(() => console.info("Inital hide of preview.")).catch(e => console.error(e));
}).catch(e => console.error(e));
//this.cameraPreview.hide().then(() => console.info("Inital Cam hide.")).catch(e => console.error(e));
}
My problem is that if i remove the initial hide command the camera-preview works fine and i can hide/show it like i want. But after i activate the cameraPreview.hide() in the then() block of startCamera() the flashlight works, but i can’t activate/show the camera preview. This is my toggle function:
toogleCamera() {
console.info("Toggle camera. CAM_STATUS: " + this.CAMERA_STATUS);
if(this.CAMERA_STATUS){
this.cameraPreview.hide().then(() => console.info("Camera hidden.")).catch(e => console.error(e));
this.CAMERA_STATUS = false;
}else{
this.cameraPreview.show().then(() => console.info("Show Camera Preview")).catch(e => console.error(e));
this.CAMERA_STATUS = true;
}
}
This is what “ionic info” shows me:
cli packages: (C:\Users\Andreas\AppData\Roaming\nvm\v7.9.0\node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 6.5.0
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : android 6.1.2
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 26.0.2
Node : v7.9.0
npm : 4.2.0
OS : Windows 10
I’m using this version of camera preview:
<plugin name="cordova-plugin-camera-preview" spec="~0.9.0" />
I cant figure out why it behaves that way.
Update: Problem solved
I solved my problem by removing the installed version of the plugin and replacing it with the most recent version from github.