Adds a camera view into your app to take pictures and record videos.
The capture method returns the image data. To save the image in DroidScript, you can use the WriteFile method like this:
// capture an image
img = cam.capture("jpeg", "base64")
filePath = "image.jpeg"
app.WriteFile(filePath, img, "base64")
img = cam.capture("jpeg", "base64")
filePath = "image.jpeg"
app.WriteFile(filePath, img, "base64")
Likewise, the record method requires a callback to be called when the video data is ready. To save videos in DroidScript, you can use the WriteFile method like this:
// record a video
cam.record("mp4", "base64", onRecord)
// in your callback function
onRecord( data ) {
filePath = "video.mp4"
app.WriteFile(filePath, data, "base64")
}
cam.record("mp4", "base64", onRecord)
// in your callback function
onRecord( data ) {
filePath = "video.mp4"
app.WriteFile(filePath, data, "base64")
}
Note: Don't forget to add permission to "Camera" and/or "Microphone" when you are taking videos.
These are the setter and getter properties for CameraView component.
Properties
The following properties are available on the CameraView object:
capabilities → Object
focusDistance → Number
focusMode → String
frameRate → Number
imageHeight → Number
img → Object
iso → Number
sound → Boolean
source → String
width → Number
Methods
The following methods are available on the CameraView object:
setOnError(
cb )
setOnReady(
cb )
stop()