How to end video trial automatically when video finishes (variable duration + optional stop key)?


Author
Message
leonsbe
leonsbe
New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)
Group: Forum Members
Posts: 1, Visits: 5
I’m trying to present videos in Inquisit, with the option for participants to press a key (“S”) to stop the video and display a “wait for experimenter” screen. After that, the experiment should continue with the next trial. Some videos are emotionally negative, so participants should be able to stop a video immediately and skip that trial if needed.

Problem:
The video trial does not end automatically when the video finishes playing. The video remains on screen and the experiment does not advance unless the stop key is pressed. However, pressing “S” should be optional.
Because the videos have different lengths, I can’t use a fixed /trialDuration.

What is the correct way to end a trial automatically when a video finishes, while having variable-length video files and giving an option to respond?

Relevant code elements below, runnable minimal version attached as zip.

<video videos>
/ items = item.video_files
/ position = (50, 50)
/ size = (60%, null)
/ select = noReplace
/ playThrough = false
/ erase = false
</video>

<item video_files>
/ 1 = "V1.mp4"
/ 2 = "V2.mp4"
/ 3 = "V3.mp4"
</item>

<trial trial_video>
/ stimulusTimes = [1 = video.videos, text.stop]
/ validresponse = (31)
/ responseInterrupt = immediate
/ branch = {
if (trial.trial_video.response == 31) return trial.stop_page;
}
</trial>

<trial stop_page>
/ stimulusTimes = [1 = text.stop_page_text]
/ validResponse = (1) // ESC key
/ ontrialend = {
    values.video_skipped = video.videos.currentItem;
}
</trial>


Thanks very much for any advice or example code.


Attachments
video_testing.zip (4 views, 2.00 MB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 109K
leonsbe - 2/2/2026
I’m trying to present videos in Inquisit, with the option for participants to press a key (“S”) to stop the video and display a “wait for experimenter” screen. After that, the experiment should continue with the next trial. Some videos are emotionally negative, so participants should be able to stop a video immediately and skip that trial if needed.

Problem:
The video trial does not end automatically when the video finishes playing. The video remains on screen and the experiment does not advance unless the stop key is pressed. However, pressing “S” should be optional.
Because the videos have different lengths, I can’t use a fixed /trialDuration.

What is the correct way to end a trial automatically when a video finishes, while having variable-length video files and giving an option to respond?

Relevant code elements below, runnable minimal version attached as zip.

<video videos>
/ items = item.video_files
/ position = (50, 50)
/ size = (60%, null)
/ select = noReplace
/ playThrough = false
/ erase = false
</video>

<item video_files>
/ 1 = "V1.mp4"
/ 2 = "V2.mp4"
/ 3 = "V3.mp4"
</item>

<trial trial_video>
/ stimulusTimes = [1 = video.videos, text.stop]
/ validresponse = (31)
/ responseInterrupt = immediate
/ branch = {
if (trial.trial_video.response == 31) return trial.stop_page;
}
</trial>

<trial stop_page>
/ stimulusTimes = [1 = text.stop_page_text]
/ validResponse = (1) // ESC key
/ ontrialend = {
    values.video_skipped = video.videos.currentItem;
}
</trial>


Thanks very much for any advice or example code.


**************************************************************************************************************
    MINIMAL TEST VERSION - 3 TRIALS ONLY
**************************************************************************************************************

<defaults>
/ minimumVersion = "7.0.0.0"
/ fontStyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ screenColor = white
/ txColor = black
</defaults>

<values>
/ video_skipped = ""
</values>


**************************************************************************************************************
    STIMULI
**************************************************************************************************************

<video videos>
/ items = item.video_files
/ playThrough = false
/ position = (50, 50)
/ size = (60%, null)
/ select = noReplace
/ erase = false
</video>

<item video_files>
/ 1 = "V1.mp4"
/ 2 = "V2.mp4"
/ 3 = "V3.mp4"
</item>

<text fixation_cross>
/ items = ("+")
/ position = (50, 50)
/ fontStyle = ("Arial", 7%, true)
</text>

<text stop>
/ items = ("press s to stop")
/ position = (90, 93)
/ size = (15%, 7%)
/ txbgcolor = lightgray
/ hjustify = center
/ vjustify = center
</text>

<text stop_page_text>
/ items = ("You have paused the experiment. Press ESC to continue.")
/ color = white
/ txBGColor = darkViolet
/ size = (100%, 100%)
/ position = (50, 50)
/ hjustify = center
/ vjustify = center
</text>

<text stop_page_no_response_text>
/ items = ("Video completed. Press ESC to continue.")
/ color = white
/ txBGColor = darkViolet
/ size = (100%, 100%)
/ position = (50, 50)
/ hjustify = center
/ vjustify = center
</text>

**************************************************************************************************************
    TRIALS
**************************************************************************************************************

<trial trial_start_baseline>
/ stimulusTimes = [1 = text.fixation_cross]
/ trialDuration = 1000
/ branch={
return trial.trial_video;
}
</trial>

<trial trial_video>
/ stop = {
    return (!video.videos.isPlaying) // stop trial when video is no longer playing
}
/ stimulusTimes = [1 = video.videos, text.stop]
/ validresponse = (31)
/ responseInterrupt = immediate
/ recordData = false
/ branch = {
    return trial.log_trial_video // when there is no response, trial_video will not record a data row; hence logging must be performed by a separate trial
}
</trial>

// this trial only exists to log variables of interest
<trial log_trial_video>
/ trialDuration = 0
/ branch = {
if (trial.trial_video.response == 31) {
        return trial.stop_page
    } else {
        return trial.stop_page_no_response
    }
}
</trial>


<trial stop_page>
/ stimulusTimes = [1 = text.stop_page_text]
/ validResponse = (1) // ESC key
/ ontrialend = {
    values.video_skipped = video.videos.currentItem;
}
</trial>

<trial stop_page_no_response>
/ stimulusTimes = [1 = text.stop_page_no_response_text]
/ validResponse = (1) // ESC key
</trial>

**************************************************************************************************************
    BLOCK
**************************************************************************************************************

<block main_video_viewing>
/ trials = [1-3 = trial_start_baseline]
</block>

**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************

<expt fullExp>
/ blocks = [1=main_video_viewing]
</expt>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search