optimisation retour video avec un element video

This commit is contained in:
2023-01-29 21:43:07 +01:00
parent 0cc80637be
commit 4374bd0694
7 changed files with 34 additions and 15 deletions

View File

@@ -1,14 +1,14 @@
class CameraPage {
constructor(canvas) {
constructor() {
this.spinnerWeight = 10;
this.spinnerColor = "#0F0FFF"
this.canvas = canvas;
this.ctx = canvas.getContext("2d");
this.video = document.createElement("video");
this.canvas = document.getElementById("overlay-canvas");
this.ctx = this.canvas.getContext("2d");
this.video = document.getElementById("camera-video");
this.width;
this.height; //calculé automatiquement en fonction de la largeur du flux vidéo
this.height; //calcule automatiquement en fonction de la largeur du flux vidéo
this.videoWidth;
this.videoHeight;
this.streaming = false;
@@ -80,9 +80,8 @@ class CameraPage {
_frame() {
if (this.streaming && this.enabled && this.width && this.height) {
this.canvas.width = this.width;
this.canvas.height = this.height;
this.ctx.drawImage(this.video, 0, 0, this.width, this.height);
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
// this.ctx.drawImage(this.video, 0, 0, this.width, this.height);
this._drawEffects();
}
if (this.enabled) {