Playing video in Psychtoolbox

Hi everyone,

I want to continually play a video whenever the right or left keyboard is being press.

For the first or 2nd loop of the video playing the last few seconds was remove. But as we press the right or left keyboard longer the full video was played.

Have anyone error issues like this?
Appreciate any suggestions. Thank you! =)

Hi, from your your message it is unclear what your exact problem is. PTB can load and play looped video files, you set up looping when you first call Screen('PlayMovie'). Please be more specific or show a minimal test case. Have you looked through the various demos, like SimpleMovieDemo.m?

Best, Ian

For the first loop the last few seconds were always chop off, but after multiple plays the full video is played.

Here is part of my code:
%% Present TEST TRIAL
while(1)
look_no = 1;
test_phrase_no=1;

            if trial.count > n_total_test_trials; 
                Advance_to_test = 0;
                break
            end
            
            if trial.order(trial.count) == 1 % Even numbers represent Left Trials
                trial.type(trial.count) = 39; % keyBoard code for Right arrow
                trial.key = 'RiteArrow';
                to_present_on_screen = Screens(1,:);
                audio_side = 2;
            elseif trial.order(trial.count) == 2 % Odd numbers represent Right Trials
                trial.type(trial.count) = 37; % keyBoard code for Left arrow
                trial.key = 'LeftArrow';
                to_present_on_screen = Screens(3,:);
                audio_side = 1;
            end                
            clear nextframe;

That code doesn’t really show the actual part that runs or updates the video; you do have a spelling mistake for the key name though: trial.key = 'RiteArrow'; – should be RightArrow

Did you check that SimpleMovieDemo works, and you can also pass your movie into PlayMovieDemo('/path/to/movie.mp4') to test it plays without cutting off…