Skip to content

Commit

Permalink
fix: control play and pause with handState
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandemonteiro committed Oct 3, 2024
1 parent aa6198d commit ba5b459
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/handControlMouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ document.body.appendChild(cursorIndicator);
let model;
let video;
let lastPosition = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
let handState = "start";

async function startCamera() {
video = document.createElement("video");
Expand Down Expand Up @@ -47,11 +48,13 @@ async function detectHand() {

moveCursor(cursorX, cursorY);

if (isHandClosed(hand)) {
if (isHandClosed(hand) && handState !== "closed") {
document.getElementById("title").innerText = "Mão fechada!";
handState = "closed";
playSound();
} else {
document.getElementById("title").innerText = "Mão aberta!";
handState = "open";
}
}

Expand Down

0 comments on commit ba5b459

Please sign in to comment.