Play sound after correct response

PennController for IBEX Forums Support Play sound after correct response

This topic contains 2 replies, has 2 voices, and was last updated by Avatar carlap 4 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6043
    Avatar
    carlap
    Participant

    Hi,

    I have the script below and my correct answers are in a table column named “Correct_answer”. What I would like is for a sound to play if the answer is correct. I tried adding this to the script: .test.pressed( row.Correct_answer) .success( newAudio("coin7.mp3"), but it results in a “ERROR: There must be some items in the running order!” error.

    Here is my script from the newKey portion. Thanks for any help!

      newKey("pressOnArrow", "ArrowLeft", "ArrowRight")   
            .log("all")
            .callback( 
                getTimer("exposure").stop(),
                getTimer("timeout").stop()
            )
       ,
        newTimer("exposure", 300).start().wait() 
        ,
        getText("num").remove()
        ,
        getKey("pressOnArrow").test.pressed()
            .failure( newTimer("timeout", 5000).start().log().wait() )
        ,
        getKey("pressOnArrow").disable()
    )
           
    .log( "Correct_answer"  , row.Correct_answer   )	
    .log( "ID" , getVar("ID")   
    ))
    #6045
    Jeremy
    Jeremy
    Keymaster

    Hi,

    This worked for me—audio file’s just an example, and I hard-coded ArrowLeft as the correct answer, but you should be able to replace it with row.Correct_answer:

        newKey("pressOnArrow", "ArrowLeft", "ArrowRight")   
            .log("all")
            .callback( 
                getTimer("exposure").stop(),
                getTimer("timeout").stop()
            )
        ,
        newTimer("exposure", 300).start().wait() 
        ,
        getText("num").remove()
        ,
        getKey("pressOnArrow").test.pressed()
            .failure( newTimer("timeout", 5000).start().log().wait() )
        ,
        getKey("pressOnArrow")
            .disable()
            .test.pressed( "ArrowLeft" )
            .success( newAudio("https://upload.wikimedia.org/wikipedia/commons/3/35/Bongo_Agudo.ogg").play().wait() )

    Let me know whether that helped fix the problem

    Jeremy

    #6050
    Avatar
    carlap
    Participant

    Works like a charm! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.