nativescript-camera-plus
nativescript-camera-plus copied to clipboard
IOS Cannot set default camera
I am trying to implement the nativescript-camera-plus plugin and I want to have the front camera be the only option available. I have tried setting the default camera usingdefaultCamera="front", but this has no effect. I have also tried the toggleCamera() function, but that also seems to do nothing. The only way I am able to switch cameras is by double tapping the camera preview.
Here is a sample of my code
<CameraPlus height="100%" verticalAlignment="top" :visibility="showCamera" ref="CameraPlus" id="camPlus"
defaultCamera="front"
saveToGallery="true"
showCaptureIcon="false"
showGalleryIcon="false"
showToggleIcon="false"
showFlashIcon="false"
debug="true"
enableVideo="false"
confirmVideo="false"
doubleTapCameraSwitch="false"
@loaded="onCameraLoaded"
@photoCapturedEvent="photoCaptured($event)"
@errorEvent="onCameraError">
</CameraPlus>
onCameraLoaded(result) {
this.cam = result.object;
//Have tried this.cam.toggleCamera();
},
takePhotoButton() {
this.image = this.cam.takePicture({ saveToGallery: false });
//This code and the code from photoCaptured work just fine.
},
Any help would be appreciated
Did you managed to make it work @matty0005 ?
@kriefsacha it's been a while since I worked on this project, but from what I remember I came up with a work-around.
I'd have to dig through my code to see what I did exactly, but it was something along the lines of setting the default camera to the rear, then after a short delay (something like 100ms), once the camera had been loaded, I would toggle the camera. This is all while the double tab switch option was disabled.
It seemed to work just fine and didn't run into many issues when testing it.