contourFinder for selecting on screen options/video player issues

Hi everyone! I’m a student working on an interactive video experience for an gallery installation. I have been using a splice of OfBook’s game example and contour finder. The idea is to detect a body entering the space with webcam and begin to play a sequence of videos in a chose your own adventure type format. Once a video is played, the viewer can respond by choosing between two options. The viewer is meant to move to the left or right to “respond” after each video is played which will trigger another video depending on the response. I’ve worked with similar apps before and always come into this issue of the audio for all the videos playing at once and haven’t been able to resolve it on this one and need a way for the videos to play all the way through before the app checks for movement again. Does this seem viable or should I change methods? I’m new to structuring game states. Including a version of the app below

#pragma once

#include “ofMain.h”
#include “ofxOpenCv.h”

class ofApp : public ofBaseApp{

public:


    void setup();
    void update();
    void draw();
    
    void draw_detect();
    void draw_blobs();
    void draw_vids();
    void play();

    ofVideoGrabber vidGrabber;
    ofxCvColorImage colorImg;
    ofxCvGrayscaleImage grayImage, grayBg, grayDiff;
    ofxCvContourFinder contourFinder;
    ofVideoPlayer good;
    ofVideoPlayer bad;
    ofVideoPlayer hello;
      
    int person;
    
    string game_state;
    int score;

    int inputNumber;

    uint64_t nextTransitionTime = 0;

};

#include “ofApp.h”

void ofApp::setup(){

vidGrabber.setVerbose(true);
vidGrabber.initGrabber(320,240);

good.load("1.mp4”);
hello.load("6.mp4");
bad.load("7.mp4");



colorImg.allocate(320,240);
grayImage.allocate(320,240);
grayBg.allocate(320,240);
grayDiff.allocate(320,240);

game_state = "wait";
   
score = 0;
person = 0;

}

void ofApp::update(){

if (game_state == "wait") {
    
score = 0;
person = 0;
    
vidGrabber.update();
   if (vidGrabber.isFrameNew()){
       colorImg.setFromPixels(vidGrabber.getPixels());
       grayImage = colorImg; // convert our color image to a grayscale image
       grayDiff.absDiff(grayBg, grayImage);
       grayDiff.threshold(30);
       contourFinder.findContours(grayDiff, 5, (340*240)/4, 4, false, true);
   }
         
} else if (game_state == "game") {
                 
        ofApp::play();
      
        hello.update();
        good.update();
        bad.update();
    
    }

}

void ofApp::draw(){

    if (game_state == "wait") {
        
        ofApp::draw_detect();
        
      } else if (game_state == "game") {	  

        ofApp::draw_blobs();

        ofApp::draw_vids();

      }

}

void ofApp::draw_detect(){

colorImg.draw(0, 0, 320, 240);
grayDiff.draw(0, 240, 320, 240);
ofDrawRectangle(320, 0, 320, 240);
contourFinder.draw(320, 0, 320, 240);
ofColor c(255, 255, 255);

for(int i = 0; i < contourFinder.nBlobs; i++) {
     ofRectangle r = contourFinder.blobs.at(i).boundingRect;
     r.x += 320; r.y += 240;
    
    ofDrawRectangle(r);
        if ( contourFinder.nBlobs >3) {
             game_state == "game";
           
        }
}

}

void ofApp::draw_blobs(){
ofSetHexColor(0xffffff);

//colorImg.draw(0, 0, 320, 240);
//grayDiff.draw(0, 240, 320, 240);
ofDrawRectangle(320, 0, 320, 240);
contourFinder.draw(320, 0, 320, 240);
ofColor c(255, 255, 255);
for(int i = 0; i < contourFinder.nBlobs; i++) {
ofRectangle r = contourFinder.blobs.at(i).boundingRect;
r.x += 320; r.y += 240;
c.setHsb(i * 64, 255, 255);
        
    ofSetColor(c);
    ofDrawRectangle(r);
    
    uint64_t now = ofGetElapsedTimeMillis();
   
             if  (now > 20000 && r.x > 500) {
                 inputNumber = 2;
                 nextTransitionTime = now + 20000; }
              if (now > 20000 && r.x < 500){
                inputNumber = 3;
                nextTransitionTime = now + 20000;
                }               
     }    

}

void ofApp::draw_vids(){

     if (hello.isPlaying() == true){
     hello.draw(0,0,972,522);
     }
     
     if (good.isPlaying() == true){
     good.draw(0,0,972,522);
     }
     
     if (bad.isPlaying() == true){
     bad.draw(0,0,972,522);
     }    

}

void ofApp::play() {

if (game_state == "game"){
hello.play();
hello.setLoopState(OF_LOOP_NONE);
score += 1;
}

if (inputNumber == 2){
bad.play();
bad.setLoopState(OF_LOOP_NONE);
score += 1;
}

if (inputNumber == 3){
good.play();
good.setLoopState(OF_LOOP_NONE);
score += 1;
}
    
else {
    vid.stop();
    hello.stop();
    bad.stop();
}


if (score < 3) {
    game_state == "wait";
          
}

}