Reply To: Play video based on presentation order

PennController for IBEX Forums Support Play video based on presentation order Reply To: Play video based on presentation order

#8384
Jeremy
Keymaster

Hi,

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()
        ,
        newScale(7).print().wait()
        ,
        // row_v points to each lines in videos.csv in a non-randomized order
        newVideo(row_v.Video).print().play().wait()
    )
)

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

Jeremy