Play video based on presentation order

PennController for IBEX Forums Support Play video based on presentation order

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #8382

    I’m programming an experiment and I want to play a short video at the end of each trial based on the presentation order: I have video 1 for the first trial that’s presented, video 2 for the second trial, and so on for a total of 4 trials in a block. Right now I randomize all the trials in this block so I cannot just refer to the videos’ file names in the trial template. Is there any convenient way to achieve what I want to do?

    I saw another post about logging running order using code like this

      newVar("runningOrder", 0).global().set(v=>v+1)

    but I’m not sure how to use it in my case.

    Thank you in advance!



    This is a little tricky indeed, since ideally you’d like to pre-associate each video with a trial based on its running order, so that the first video starts preloading before the second video and so forth, but the running order is randomized

    One trick would consist in randomizing the table itself (the one that contains the stim details for the trials) rather than randomizing the trials in the Sequence, so that you output newTrials generated from the randomized table, but with the video references taken from another, non-randomized table

    Say you have two CSV files in your project, one named “stims.csv” and one name “videos.csv” (the latter only lists video references in the order in which they are supposed to play). Then you can do something like this:

    // we will store the stim details in an array named 'trials' (which we will randomize)
    var trials = []
    // fill 'trials' with each row from stims.csv
    Template( "stims.csv", row => [ trials.push(row) ] )
    // we will successively retrieve each row from 'trials' in 'row'
    var row
    // generate trials from video.csv, where row_w points to each of its lines
    Template( "videos.csv", row_v =>
        newTrial( "trial" ,
            fisherYates(trials),  // randomize the array 'trials'
            row = trials.pop()    // move the last entry of 'trials' into 'row'
            // write your trial as usual, with 'row' pointing to a random line from 'stims.csv'
            newText( row.Sentence ).print()
            newText( row.Question ).print()
            // row_v points to each lines in videos.csv in a non-randomized order

    NB: you might see errors about not finding a column named _promises, you can safely ignore those specific errors (they come from the line row = trials.pop() which is not very standard syntax)

    Let me know if you have questions


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