Ensure the audio files have been played before moving on

PennController for IBEX Forums Support Ensure the audio files have been played before moving on

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6803
    gzlkj
    Participant

    Hi,

    I have two audio files in each trial and a selector element. I want to make sure the participants have clicked on the play button of the two files before selecting one of the options from the selector. My first idea was to use the .test.hasPlayed command in a wait condition for a button then move on to the selector element, but that resulted in having me click on the button twice. I might have other trials where there’s only one audio, but I thought there should be a better simpler solution for this that I’m not seeing in the documentation. Although I found this other post about clicking on buttons, I wasn’t sure how I could implement it similarly for this trial I have (code below):

    newTrial ("practice" ,
    
        newCanvas("audio", 800, 80)
            .add(   20, 18, newAudio("soundl", row.PL_Audio) )
            .add( 500, 18,  newAudio("soundr", row.PR_Audio) )
            .print()
            .center()
    ,
        newCanvas("pairs", 800, 200)
            .add(   80, 60, newText("left", row.PL) )
            .add( 560, 60, newText("right", row.PR) )
            .print()
            .center()
    
    ,
    newSelector("comparison")
        .add( getText("left") , getText("right") )
        .print()
        .wait()
        .log()
        .once()
    )
    
    

    and I also wanted to say thanks for the effort you put in for making the new farm available. It’s amazing!

    -Zara

    #6804
    Jeremy
    Keymaster

    Hi Zara,

    Using .test.hasPlayed sounds like a good idea, and there would be a way to make it work. But if you want to automatically move on to the Selector element immediately after the second audio has played back, there is a simpler way: just insert getAudio("soundl").wait("first"),getAudio("soundr").wait("first") before the newSelector line. Because of the "first" argument, even if soundl is played after soundr, the two waits will be validated in a row because "first" in the second wait will automatically detect that soundr was played back before

    Let me know if that worked

    Jeremy

    #6807
    gzlkj
    Participant

    Thank you! It looks like it’s working as it should.
    I really appreciate the quick reply, that was helpful. I’ve seen the “first” argument somewhere in the documentation of the old farm before, but it didn’t occur to me that I can use it here.

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