I have tried to write my script using the code in playMoviesWithoutGapDemo2 because the movies are all the same except the content.I have 12 movies and each has 30 frames.The frame rate was 30 frames per second.And I need to play the 12 movies without repetition.So the script was changed to :
%%%%%%%%%%%%%%%%%
Thistrialseq=Shuffle([1:12])';%There are 12 different movies.
[MoviePtr]=Screen('OpenMovie',windowPtr,[MoviePath '\' num2str(Thistrialseq(1)) '.mp4']);%open the first movie;
prefetched = 0;
lastpts = -1;
for trial=1:size( Thistrialseq,1)
if trial moviename=[MoviePath '\' num2str(Thistrialseq(trial+1)) '.mp4'];%the name of next movie;
end
touch=0;
count=0;
while ~(touch==1&&keyCode(escapeKey))
[tex,pts] = Screen('GetMovieImage', windowPtr,MoviePtr);
if tex break;
end
Screen('DrawTexture', windowPtr,tex);
Screen('Flip', windowPtr);
Screen('Close', tex);
[touch, secs, keyCode] = KbCheck;
if prefetched==0 && pts > 0
if trial