metag-sdk-ionic 1.2.7-native-0.134 → 1.2.7-native-0.136
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.
|
@@ -381,19 +381,13 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
381
381
|
|
|
382
382
|
// Vista personalizada que combina TextureView (preview) + Canvas (UI)
|
|
383
383
|
private class CameraOverlayView extends FrameLayout {
|
|
384
|
-
|
|
385
|
-
private
|
|
386
|
-
private Paint textPaint;
|
|
387
|
-
private Paint buttonPaint;
|
|
388
|
-
private RectF recordButton;
|
|
389
|
-
private RectF closeButton;
|
|
390
|
-
private CustomVideoRecorder plugin;
|
|
384
|
+
public TextureView textureView;
|
|
385
|
+
private OverlayDrawView overlayDrawView;
|
|
391
386
|
|
|
392
387
|
public CameraOverlayView(android.content.Context context, CustomVideoRecorder plugin) {
|
|
393
388
|
super(context);
|
|
394
|
-
this.plugin = plugin;
|
|
395
389
|
|
|
396
|
-
// TextureView para preview de cámara
|
|
390
|
+
// TextureView para preview de cámara (fondo)
|
|
397
391
|
textureView = new TextureView(context);
|
|
398
392
|
textureView.setSurfaceTextureListener(surfaceTextureListener);
|
|
399
393
|
addView(textureView, new FrameLayout.LayoutParams(
|
|
@@ -401,6 +395,34 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
401
395
|
FrameLayout.LayoutParams.MATCH_PARENT
|
|
402
396
|
));
|
|
403
397
|
|
|
398
|
+
// Vista de dibujo encima del preview
|
|
399
|
+
overlayDrawView = new OverlayDrawView(context, plugin);
|
|
400
|
+
addView(overlayDrawView, new FrameLayout.LayoutParams(
|
|
401
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
402
|
+
FrameLayout.LayoutParams.MATCH_PARENT
|
|
403
|
+
));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
public void updateUI() {
|
|
407
|
+
if (overlayDrawView != null) {
|
|
408
|
+
overlayDrawView.invalidate();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Vista que dibuja los overlays (botones, texto, etc.)
|
|
414
|
+
private class OverlayDrawView extends View {
|
|
415
|
+
private Paint paint;
|
|
416
|
+
private Paint textPaint;
|
|
417
|
+
private Paint buttonPaint;
|
|
418
|
+
private RectF recordButton;
|
|
419
|
+
private RectF closeButton;
|
|
420
|
+
private CustomVideoRecorder plugin;
|
|
421
|
+
|
|
422
|
+
public OverlayDrawView(android.content.Context context, CustomVideoRecorder plugin) {
|
|
423
|
+
super(context);
|
|
424
|
+
this.plugin = plugin;
|
|
425
|
+
|
|
404
426
|
// Configurar paints
|
|
405
427
|
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
406
428
|
|
|
@@ -417,7 +439,6 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
417
439
|
recordButton = new RectF();
|
|
418
440
|
closeButton = new RectF();
|
|
419
441
|
|
|
420
|
-
setWillNotDraw(false);
|
|
421
442
|
setClickable(true);
|
|
422
443
|
}
|
|
423
444
|
|
|
@@ -505,10 +526,6 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
505
526
|
getContext().getResources().getDisplayMetrics()
|
|
506
527
|
);
|
|
507
528
|
}
|
|
508
|
-
|
|
509
|
-
public void updateUI() {
|
|
510
|
-
invalidate();
|
|
511
|
-
}
|
|
512
529
|
}
|
|
513
530
|
|
|
514
531
|
private void startCountdown() {
|
|
@@ -553,14 +570,27 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
553
570
|
null,
|
|
554
571
|
backgroundHandler
|
|
555
572
|
);
|
|
556
|
-
mediaRecorder.start();
|
|
557
|
-
isRecording = true;
|
|
558
|
-
timeRemaining = 5;
|
|
559
|
-
overlayView.updateUI();
|
|
560
573
|
|
|
561
|
-
|
|
574
|
+
// Iniciar MediaRecorder
|
|
575
|
+
try {
|
|
576
|
+
mediaRecorder.start();
|
|
577
|
+
isRecording = true;
|
|
578
|
+
timeRemaining = 5;
|
|
579
|
+
|
|
580
|
+
getActivity().runOnUiThread(() -> {
|
|
581
|
+
if (overlayView != null) {
|
|
582
|
+
overlayView.updateUI();
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
startRecordingTimer();
|
|
587
|
+
} catch (Exception startEx) {
|
|
588
|
+
startEx.printStackTrace();
|
|
589
|
+
isRecording = false;
|
|
590
|
+
}
|
|
562
591
|
} catch (Exception e) {
|
|
563
592
|
e.printStackTrace();
|
|
593
|
+
isRecording = false;
|
|
564
594
|
}
|
|
565
595
|
}
|
|
566
596
|
|
|
@@ -579,8 +609,15 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
579
609
|
Runnable timerRunnable = new Runnable() {
|
|
580
610
|
@Override
|
|
581
611
|
public void run() {
|
|
612
|
+
if (!isRecording) return; // Salir si ya no está grabando
|
|
613
|
+
|
|
582
614
|
timeRemaining--;
|
|
583
|
-
|
|
615
|
+
|
|
616
|
+
getActivity().runOnUiThread(() -> {
|
|
617
|
+
if (overlayView != null) {
|
|
618
|
+
overlayView.updateUI();
|
|
619
|
+
}
|
|
620
|
+
});
|
|
584
621
|
|
|
585
622
|
if (timeRemaining > 0) {
|
|
586
623
|
handler.postDelayed(this, 1000);
|
|
@@ -593,21 +630,58 @@ public class CustomVideoRecorder extends Plugin {
|
|
|
593
630
|
}
|
|
594
631
|
|
|
595
632
|
private void stopRecordingInternal() {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
633
|
+
getActivity().runOnUiThread(() -> {
|
|
634
|
+
try {
|
|
635
|
+
if (mediaRecorder != null) {
|
|
636
|
+
try {
|
|
637
|
+
mediaRecorder.stop();
|
|
638
|
+
} catch (RuntimeException e) {
|
|
639
|
+
// Ignorar si ya estaba detenido
|
|
640
|
+
e.printStackTrace();
|
|
641
|
+
}
|
|
642
|
+
mediaRecorder.reset();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
isRecording = false;
|
|
646
|
+
|
|
647
|
+
if (overlayView != null) {
|
|
648
|
+
overlayView.updateUI();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// Notificar al JavaScript con el path del video
|
|
652
|
+
JSObject ret = new JSObject();
|
|
653
|
+
ret.put("success", true);
|
|
654
|
+
ret.put("videoPath", videoFilePath);
|
|
655
|
+
notifyListeners("recordingComplete", ret);
|
|
656
|
+
|
|
657
|
+
// Cerrar el preview después de notificar (dar tiempo al JS para procesar)
|
|
658
|
+
new Handler().postDelayed(() -> {
|
|
659
|
+
try {
|
|
660
|
+
closeCamera();
|
|
661
|
+
if (overlayView != null) {
|
|
662
|
+
ViewGroup parent = (ViewGroup) overlayView.getParent();
|
|
663
|
+
if (parent != null) {
|
|
664
|
+
parent.removeView(overlayView);
|
|
665
|
+
}
|
|
666
|
+
overlayView = null;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
getBridge().getWebView().setBackgroundColor(0xFFFFFFFF);
|
|
670
|
+
getBridge().getWebView().setVisibility(View.VISIBLE);
|
|
671
|
+
} catch (Exception e) {
|
|
672
|
+
e.printStackTrace();
|
|
673
|
+
}
|
|
674
|
+
}, 500);
|
|
675
|
+
|
|
676
|
+
} catch (Exception e) {
|
|
677
|
+
e.printStackTrace();
|
|
678
|
+
|
|
679
|
+
// En caso de error, notificar también
|
|
680
|
+
JSObject ret = new JSObject();
|
|
681
|
+
ret.put("success", false);
|
|
682
|
+
ret.put("error", e.getMessage());
|
|
683
|
+
notifyListeners("recordingComplete", ret);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
612
686
|
}
|
|
613
687
|
}
|
package/package.json
CHANGED