metag-sdk-ionic 1.2.7-native-0.135 → 1.2.7-native-0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -64,16 +64,20 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
64
64
|
|
|
65
65
|
@PluginMethod
|
|
66
66
|
public void startPreview(PluginCall call) {
|
|
67
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Iniciando preview de cámara");
|
|
67
68
|
if (!hasRequiredPermissions()) {
|
|
69
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: No se tienen los permisos necesarios");
|
|
68
70
|
call.reject("No se tienen los permisos necesarios");
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
getActivity().runOnUiThread(() -> {
|
|
73
75
|
try {
|
|
76
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Obteniendo WebView parent");
|
|
74
77
|
ViewGroup webViewParent = (ViewGroup) getBridge().getWebView().getParent();
|
|
75
78
|
|
|
76
79
|
// Crear vista de overlay nativo con preview y UI
|
|
80
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Creando CameraOverlayView");
|
|
77
81
|
overlayView = new CameraOverlayView(getContext(), this);
|
|
78
82
|
|
|
79
83
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
|
@@ -81,14 +85,18 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
81
85
|
FrameLayout.LayoutParams.MATCH_PARENT
|
|
82
86
|
);
|
|
83
87
|
webViewParent.addView(overlayView, params);
|
|
88
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Overlay agregado al WebView parent");
|
|
84
89
|
|
|
85
90
|
getBridge().getWebView().setBackgroundColor(0x00000000);
|
|
86
91
|
getBridge().getWebView().setVisibility(View.GONE);
|
|
92
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: WebView ocultado, preview iniciado correctamente");
|
|
87
93
|
|
|
88
94
|
JSObject ret = new JSObject();
|
|
89
95
|
ret.put("success", true);
|
|
90
96
|
call.resolve(ret);
|
|
91
97
|
} catch (Exception e) {
|
|
98
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Exception en startPreview: " + e.getMessage());
|
|
99
|
+
e.printStackTrace();
|
|
92
100
|
call.reject("Error al iniciar preview: " + e.getMessage());
|
|
93
101
|
}
|
|
94
102
|
});
|
|
@@ -529,6 +537,7 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
529
537
|
}
|
|
530
538
|
|
|
531
539
|
private void startCountdown() {
|
|
540
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Iniciando countdown de 3 segundos");
|
|
532
541
|
countdown = 3;
|
|
533
542
|
overlayView.updateUI();
|
|
534
543
|
|
|
@@ -537,11 +546,13 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
537
546
|
@Override
|
|
538
547
|
public void run() {
|
|
539
548
|
countdown--;
|
|
549
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Countdown: " + countdown);
|
|
540
550
|
overlayView.updateUI();
|
|
541
551
|
|
|
542
552
|
if (countdown > 0) {
|
|
543
553
|
handler.postDelayed(this, 1000);
|
|
544
554
|
} else {
|
|
555
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Countdown terminado, iniciando grabación");
|
|
545
556
|
startRecordingInternal();
|
|
546
557
|
}
|
|
547
558
|
}
|
|
@@ -570,14 +581,27 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
570
581
|
null,
|
|
571
582
|
backgroundHandler
|
|
572
583
|
);
|
|
573
|
-
mediaRecorder.start();
|
|
574
|
-
isRecording = true;
|
|
575
|
-
timeRemaining = 5;
|
|
576
|
-
overlayView.updateUI();
|
|
577
584
|
|
|
578
|
-
|
|
585
|
+
// Iniciar MediaRecorder
|
|
586
|
+
try {
|
|
587
|
+
mediaRecorder.start();
|
|
588
|
+
isRecording = true;
|
|
589
|
+
timeRemaining = 5;
|
|
590
|
+
|
|
591
|
+
getActivity().runOnUiThread(() -> {
|
|
592
|
+
if (overlayView != null) {
|
|
593
|
+
overlayView.updateUI();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
startRecordingTimer();
|
|
598
|
+
} catch (Exception startEx) {
|
|
599
|
+
startEx.printStackTrace();
|
|
600
|
+
isRecording = false;
|
|
601
|
+
}
|
|
579
602
|
} catch (Exception e) {
|
|
580
603
|
e.printStackTrace();
|
|
604
|
+
isRecording = false;
|
|
581
605
|
}
|
|
582
606
|
}
|
|
583
607
|
|
|
@@ -596,8 +620,15 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
596
620
|
Runnable timerRunnable = new Runnable() {
|
|
597
621
|
@Override
|
|
598
622
|
public void run() {
|
|
623
|
+
if (!isRecording) return; // Salir si ya no está grabando
|
|
624
|
+
|
|
599
625
|
timeRemaining--;
|
|
600
|
-
|
|
626
|
+
|
|
627
|
+
getActivity().runOnUiThread(() -> {
|
|
628
|
+
if (overlayView != null) {
|
|
629
|
+
overlayView.updateUI();
|
|
630
|
+
}
|
|
631
|
+
});
|
|
601
632
|
|
|
602
633
|
if (timeRemaining > 0) {
|
|
603
634
|
handler.postDelayed(this, 1000);
|
|
@@ -610,21 +641,71 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
610
641
|
}
|
|
611
642
|
|
|
612
643
|
private void stopRecordingInternal() {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
644
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Deteniendo grabación");
|
|
645
|
+
getActivity().runOnUiThread(() -> {
|
|
646
|
+
try {
|
|
647
|
+
if (mediaRecorder != null) {
|
|
648
|
+
try {
|
|
649
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Llamando mediaRecorder.stop()");
|
|
650
|
+
mediaRecorder.stop();
|
|
651
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: MediaRecorder detenido correctamente");
|
|
652
|
+
} catch (RuntimeException e) {
|
|
653
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: RuntimeException al detener: " + e.getMessage());
|
|
654
|
+
e.printStackTrace();
|
|
655
|
+
}
|
|
656
|
+
mediaRecorder.reset();
|
|
657
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: MediaRecorder reseteado");
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
isRecording = false;
|
|
661
|
+
|
|
662
|
+
if (overlayView != null) {
|
|
663
|
+
overlayView.updateUI();
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Notificar al JavaScript con el path del video
|
|
667
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Video grabado en: " + videoFilePath);
|
|
668
|
+
JSObject ret = new JSObject();
|
|
669
|
+
ret.put("success", true);
|
|
670
|
+
ret.put("videoPath", videoFilePath);
|
|
671
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Notificando a JavaScript");
|
|
672
|
+
notifyListeners("recordingComplete", ret);
|
|
673
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Notificación enviada");
|
|
674
|
+
|
|
675
|
+
// Cerrar el preview después de notificar (dar tiempo al JS para procesar)
|
|
676
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Programando cierre del preview en 500ms");
|
|
677
|
+
new Handler().postDelayed(() -> {
|
|
678
|
+
try {
|
|
679
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Cerrando cámara y limpiando vista");
|
|
680
|
+
closeCamera();
|
|
681
|
+
if (overlayView != null) {
|
|
682
|
+
ViewGroup parent = (ViewGroup) overlayView.getParent();
|
|
683
|
+
if (parent != null) {
|
|
684
|
+
parent.removeView(overlayView);
|
|
685
|
+
}
|
|
686
|
+
overlayView = null;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
getBridge().getWebView().setBackgroundColor(0xFFFFFFFF);
|
|
690
|
+
getBridge().getWebView().setVisibility(View.VISIBLE);
|
|
691
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Vista limpiada, WebView restaurado");
|
|
692
|
+
} catch (Exception e) {
|
|
693
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Exception al limpiar: " + e.getMessage());
|
|
694
|
+
e.printStackTrace();
|
|
695
|
+
}
|
|
696
|
+
}, 500);
|
|
697
|
+
|
|
698
|
+
} catch (Exception e) {
|
|
699
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Exception crítica: " + e.getMessage());
|
|
700
|
+
e.printStackTrace();
|
|
701
|
+
|
|
702
|
+
// En caso de error, notificar también
|
|
703
|
+
JSObject ret = new JSObject();
|
|
704
|
+
ret.put("success", false);
|
|
705
|
+
ret.put("error", e.getMessage());
|
|
706
|
+
android.util.Log.e("CustomVideoRecorder", "ERROR: Notificando error a JavaScript");
|
|
707
|
+
notifyListeners("recordingComplete", ret);
|
|
708
|
+
}
|
|
709
|
+
});
|
|
629
710
|
}
|
|
630
711
|
}
|
package/package.json
CHANGED