Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previaÚltima revisiónAmbos lados, revisión siguiente | ||
wiki:2.-desarrollo-app:2.5.-controles-by-xone:p.-camara:start [2019/09/13 14:23] – [Cámara by XOne] ary | wiki:2.-desarrollo-app:2.5.-controles-by-xone:p.-camara:start [2019/09/16 15:02] – ary | ||
---|---|---|---|
Línea 13: | Línea 13: | ||
donde " | donde " | ||
\\ | \\ | ||
+ | |||
__Estas funciones son:__ | __Estas funciones son:__ | ||
Línea 44: | Línea 45: | ||
| | ||
* control.setOnCodeScanned, | * 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; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ |