response while reproducing video

PennController for IBEX Forums Support response while reproducing video

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5268
    sblanch
    Participant

    Good morning Jeremy
    Is it possible to get keyboard or other response from participants while we are reproducing the videos?
    We wanna have the participant reponse when something happens in our video …
    Thanks again! thank you for your help and your quick response
    Kind regards
    Sílvia

    #5269
    Jeremy
    Keymaster

    Hello Sílvia,

    Yes, you can use Key elements as usual. Just remember that the script runs top-down and pauses on every wait command. Here’s an example:

    newTrial(
        newText("Press Space when you see another 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()
        ,
        newTimer("tooearly", 2500).start(),
        newTimer("toolate", 3500).start()
        ,
        newKey(" ").wait()
        ,
        getVideo("video").pause()
        ,
        getTimer("tooearly").test.ended()
            .and( getTimer("toolate").test.running() )
            .success( newText("Good job!").print() )
            .failure( newText("Too early, or too late!").print() )
        ,
        newButton("Next").print().wait()
    )

    Jeremy

    #5270
    sblanch
    Participant

    Thank you Jeremy!
    But it seems to work with just one response during the video, isn’t it? can we do like a while loop to look the responses during all the video? is it possible?
    Thanks again!
    Sílvia

    #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

    #5274
    sblanch
    Participant

    Thank you Jeremy!!!!!!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.