Laxmikant Dange
Laxmikant Dange

Reputation: 7688

How to access camera in nativescript?

How to access camera in nativescript without opening camera activity?

I used following code but it is opening device camera application. And I am expecting it should take picture without opening camera, or add camera view in application itself like whatsapp web scan.

import cameraModule = require("camera");
import imageModule = require("ui/image");
cameraModule.takePicture().then(picture => {
    console.log("Result is an image source instance");
    var image = new imageModule.Image();
    image.imageSource = picture;
});

Upvotes: 0

Views: 2212

Answers (1)

Vladimir Amiorkov
Vladimir Amiorkov

Reputation: 2901

The "camera" module of NativeScript is an abstraction for the OS specific camera module which is why it opens that native interface.

In order to open a custom "nested" camera view a custom implementation would be required. Here comes the power of NativeScript and more specifically its plugin extensibility. You can either write such plugin yourself or looks for an existing one. As the idea of "nested" camera UI is very specific and would probably rely on app specific styles I was not able to find such existing plugin. Here for example you can see how something like this would be implemented in native Android, the same is probably possible in iOS also.

Upvotes: 2

Related Questions