Reply To: response while reproducing video

PennController for IBEX Forums Support response while reproducing video Reply To: response while reproducing video

#5272
Jeremy
Keymaster

I’m not sure a while loop would be the way to go, but maybe you’d want to use the callback command. It really depends on what design you have in mind. But again, there’s nothing special about playing back a video, really. Just code your trial the way you would code any other trial. Here’s another example:

newTrial(
    newText("Press Space whenever you see a second boat in the video").print()
    ,
    newButton("Watch video").print().wait().remove()
    ,
    newVideo("video", "https://upload.wikimedia.org/wikipedia/commons/4/4f/CanoeTacking.webm")
        .size("auto","60vh")
        .print()
        .play()
        .log()
    ,
    newText("Number of presses on the Spacebar...")
        .after( newText("times", "0") )
        .print()
    ,
    newVar("presses", 0)
    ,
    newKey(" ")
        .log("all")
        .callback( 
            getVar("presses").set(v=>v+1),
            getText("times").text( getVar("presses") )
        )
    ,
    getVideo("video").wait()
    ,
    getVar("presses").test.is(2)
        .success( newText("Indeed, there were exactly two other boats").print() )
        .failure( newText("Did you miss something, or did you see ghost boats?").print() )
    ,
    newButton("Next").print().wait()
)

Jeremy