Hi all,
I am trying to play a video backwards and forwards depending on key press. For example, if I press Right Arrow, I want to step forward in the video, and if I press Left Arrow I want to reverse the video.
The issue is that my video keep on closing after Forward Step >> Backward Step >> Forward Step and I do not understand why.
I would be grateful if anyone could help.
Thank you!
N
% Open Movie file
[movie, duration, fps]= Screen('OpenMovie', win, movieName);
% Playback loop: Runs until end of movie or keypress:
while 1
% Check which key is pressed:
[~, ~, keyCode] = KbCheck;
% Valid texture returned? A negative value means end of movie reached:
if tex <= 0
% We're done, break out of loop:
break;
% Stop loop if ESC is pressed:
elseif keyCode(41) == 1 %Windows 27; Mac 41
% We're done, break out of loop:
break;
% Play movie backward while LeftArrow is pressed:
elseif keyCode(80) %Windows 37; Mac 80
% Start backward playback:
Screen('PlayMovie', movie, -1);
% Get next video frame:
GetNextFrame
% Stop playback:
Screen('PlayMovie', movie, 0);
disp(timeStamp)
% Play movie forward while RightArrow is pressed:
elseif keyCode(79) == 1 %Windows 39; Mac 79
% Start forward playback:
Screen('PlayMovie', movie, 1);
% Get next video frame:
GetNextFrame
% Stop playback:
Screen('PlayMovie', movie, 0);
disp(timeStamp)
% IF end:
end
% WHILE end:
end
% Close movie:
Screen('CloseMovie', movie);
Natasa Ganea