How to use code to define a parameter (i.e. variable selected from conditions csv file)

In my experiment I am presenting movie files via a routine generated in experiment builder. Which movie file plays depends on: (1) which audio file precedes it (1 of 10, selected by the experimenter during the experiment) and (2) which trial we are on (from a loop of 4 trials). I have a csv file defining the Conditions in the loop. For each audio clip 1-10, there is a parameter in the csv (video1, video2 etc). And beneath the column heading, there are file paths for 4 different video clips for each of video1, video2 etc (e.g. video1_A, video1_B, video1_C, etc.)
In the movie component in experiment builder, I define the Movie file as $video1, $video2 etc. And then depending on which of the four stimulus trials we are on, it will play, e.g. video1_A, video1_B, video1_C, etc.
At the moment, I have had to add each of the potential video elements ($video1, $video2 etc.) in series as separate routines, with a coding element that says whether or not to run the routine (depending on which audio file the experimenter selected). This seems to be causing a huge delay on the video file playing, especially for the later components.
I am trying to work out if/how I can add the video in as one routine rather than 10 different ones. So I would (presumably) want some coding element to precede this routine that lets me define whether the Movie file should be $video1, $video2… etc. This is where I’m stuck. I can’t figure out how to code that so that it is recognised as a parameter in the csv file. I have tried adding the coding element video=”video1” or video=”$video1” and defining the Movie file as $video. Or the coding element as video=”$video1” and defining the Movie file as video. However I do it, it doesn’t recognise the parameter.
I hope the question makes sense and thank you so much to anyone willing to help.

I managed to fix this problem (where ‘trials’ is the name of my loop) using (in the code component):

current_trial_data = trials.trialList[trials.thisIndex]

And in the movie component:
Movie file = $video