Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa | |||
wiki:2.-desarrollo-app:2.5.-controles-by-xone:p.-camara:start [2019/09/16 14:02] ary |
— (actual) | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | |||
- | {{indexmenu_n> | ||
- | ===== Cámara by XOne ===== | ||
- | |||
- | |||
- | \\ | ||
- | |||
- | XOne entre sus bondades, ha implementado un módulo de cámara, brindando excelentes potencialidades para esta función. | ||
- | Esta queda embebida en la propia ventana desde la que es invocada .\\ | ||
- | \\ | ||
- | Las funciones que brinda este control Cámara se obtienen haciendo | ||
- | let control = getControl(" | ||
- | donde " | ||
- | \\ | ||
- | |||
- | __Estas funciones son:__ | ||
- | |||
- | * control.takePicture(params); | ||
- | |||
- | * control.record(params); | ||
- | |||
- | * control.stopRecording(); | ||
- | |||
- | * control.setFlashMode(sFlashMode); | ||
- | |||
- | * control.setCamera(" | ||
- | |||
- | * control.startPreview(), | ||
- | |||
- | * control.stopPreview(), | ||
- | | ||
- | * control.isCameraOpened(), | ||
- | |||
- | * control.setAutoFocus, | ||
- | | ||
- | * control.isAutoFocus(), | ||
- | | ||
- | * control.getSupportedAspectRatios(), | ||
- | | ||
- | * control.getSupportedVideoProfiles(), | ||
- | | ||
- | * control.getMaxZoom(), | ||
- | | ||
- | * control.setZoom(nZoom), | ||
- | | ||
- | * control.setOnCodeScanned, | ||
- | |||
- | \\ | ||
- | Ejemplo: | ||
- | |||
- | \\ | ||
- | |||
- | |||
- | |||
- | <code javascript> | ||
- | <coll name=" | ||
- | <group name=" | ||
- | <frame name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | </ | ||
- | </ | ||
- | | ||
- | <group name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <frame name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | </ | ||
- | </ | ||
- | | ||
- | <group name=" | ||
- | <frame name=" | ||
- | <frame name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | </ | ||
- | <prop name=" | ||
- | <frame name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | <prop name=" | ||
- | </ | ||
- | | ||
- | </ | ||
- | <prop name=" | ||
- | </ | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | <code javascript> | ||
- | |||
- | function takePicture() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | var params = { | ||
- | filename | ||
- | saveToGallery: | ||
- | width : 360, | ||
- | height | ||
- | onFinished | ||
- | if (!sFileName) { | ||
- | ui.showToast(" | ||
- | } else { | ||
- | ui.showToast(" | ||
- | ui.openFile(sFileName); | ||
- | } | ||
- | } | ||
- | }; | ||
- | control.takePicture(params); | ||
- | } | ||
- | |||
- | function record() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | | ||
- | var currentObj = self; | ||
- | let params = { | ||
- | quality | ||
- | maxDuration : 10000, | ||
- | // | ||
- | withMicAudio: | ||
- | onFinished | ||
- | self.MAP_RECORDING=0; | ||
- | ui.refresh(" | ||
- | if (!sFileName) { | ||
- | ui.showToast(" | ||
- | } else { | ||
- | ui.showToast(" | ||
- | ui.openFile(sFileName); | ||
- | } | ||
- | } | ||
- | }; | ||
- | control.record(params); | ||
- | self.MAP_RECORDING=1; | ||
- | ui.refresh(" | ||
- | } | ||
- | |||
- | function stopRecording() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.stopRecording(); | ||
- | } | ||
- | |||
- | function startPreview() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.startPreview(); | ||
- | } | ||
- | |||
- | function stopPreview() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.stopPreview(); | ||
- | } | ||
- | |||
- | function isOpened() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | let bOpened = control.isCameraOpened(); | ||
- | ui.showToast(" | ||
- | } | ||
- | |||
- | function isAutoFocus() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | let bAutoFocus = control.isAutoFocus(); | ||
- | ui.showToast(" | ||
- | } | ||
- | |||
- | function getSupportedAspectRatios() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | let allAspectRatios = control.getSupportedAspectRatios(); | ||
- | let sMessage = " | ||
- | for (let i = 0;i < allAspectRatios.length; | ||
- | sMessage = sMessage + " | ||
- | } | ||
- | ui.msgBox(sMessage, | ||
- | } | ||
- | |||
- | function doSetOnCodeScanned() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.setOnCodeScanned(function(evento) { | ||
- | let nResult = ui.msgBox(" | ||
- | if (nResult == 6) { | ||
- | return true; | ||
- | } else { | ||
- | return false; | ||
- | } | ||
- | }); | ||
- | } | ||
- | |||
- | /** | ||
- | * Modifica el comportamiento de flash de la cámara. | ||
- | | ||
- | * Valores posibles: | ||
- | * 1) on: Siempre encendido al tomar una foto | ||
- | * 2) off: Siempre apagado al tomar una foto | ||
- | * 3) torch: Siempre encendido | ||
- | * 4) auto: Encendido o apagado al tomar una foto dependiendo de lo que diga el | ||
- | * sensor de luz | ||
- | * 5) red_eye: Encendido o apagado al tomar una foto dependiendo de lo que diga | ||
- | * el sensor de luz, en un modo especial que reduce los ojos rojos | ||
- | */ | ||
- | function doSetFlashMode(sFlashMode) { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.setFlashMode(sFlashMode); | ||
- | } | ||
- | |||
- | function doToggleFlashMode() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | let sFlashMode = control.getFlashMode(); | ||
- | if (sFlashMode == " | ||
- | control.setFlashMode(" | ||
- | self.setFieldPropertyValue(" | ||
- | } else if (sFlashMode == " | ||
- | control.setFlashMode(" | ||
- | self.setFieldPropertyValue(" | ||
- | } else if (sFlashMode == " | ||
- | control.setFlashMode(" | ||
- | self.setFieldPropertyValue(" | ||
- | } else if (sFlashMode == " | ||
- | control.setFlashMode(" | ||
- | self.setFieldPropertyValue(" | ||
- | } | ||
- | ui.refresh(" | ||
- | } | ||
- | |||
- | function doToggleCamera() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | let sCamera = control.getCamera(); | ||
- | if (sCamera == " | ||
- | control.setCamera(" | ||
- | } else if (sCamera == " | ||
- | control.setCamera(" | ||
- | } | ||
- | } | ||
- | |||
- | function doToggleAutoFocus() { | ||
- | let control = getControl(" | ||
- | if (!control) { | ||
- | return; | ||
- | } | ||
- | control.setAutoFocus(!control.isAutoFocus()); | ||
- | } | ||
- | |||
- | function getControl(sPropName) { | ||
- | let window = ui.getView(self); | ||
- | if (!window) { | ||
- | return null; | ||
- | } | ||
- | let control = window[sPropName]; | ||
- | if (!control) { | ||
- | return null; | ||
- | } | ||
- | return control; | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||