stopping movie playback

Hi all, I am having trouble with stopping movie playback using
Screen(PlayMovie). Here is the script I am using:


for i=1:ntrials;

film=strcat('/Users/jeph/Documents/Psychtoolbox_experiments/scam/movies/',char(moviename(i)));

[movie] = Screen('OpenMovie', win, film);

Screen('PlayMovie', movie, 1, 0, 1.0);

movietexture=0;

while(movietexture>=0)

[movietexture] = Screen('GetMovieImage', win, movie, 0);

if (movietexture>0)
Screen('DrawTexture', win, movietexture);
Screen('Flip', win);
Screen('Close', movietexture);
movietexture=0;
end;

[keyIsDown, secs, keyCode]=KbCheck;
if (keyIsDown==1)
if keyCode(KbName('ESCAPE'))
droppedframes=Screen('PlayMovie', movie, 0, 0, 0);
Screen('CloseMovie', movie);
break;
end;
end;
end;

Screen('PlayMovie', movie, 0, 0, 0);
Screen('CloseMovie', movie);
end


Whenever I press ESC to stop playback, it gives the error message that
the movie handle does not exist. It does not have any problem when the
same code is used after the display while loop (no error then). Any ideas?

Thanks in advance,

- Jeff
Simple: You close the movie in your if(kbName('EsCAPe...
statement, then break out of the while loop, then try
to stop/close the movie agan that's been closed already,
so its handle is invalid --> error.

-mario

--- In psychtoolbox@yahoogroups.com, "lejeph" <jloucks@...> wrote:
>
> Hi all, I am having trouble with stopping movie playback using
> Screen(PlayMovie). Here is the script I am using:
>
>
> for i=1:ntrials;
>
> film=strcat('/Users/jeph/Documents/Psychtoolbox_experiments/scam/movies/',char
(moviename(i)));
>
> [movie] = Screen('OpenMovie', win, film);
>
> Screen('PlayMovie', movie, 1, 0, 1.0);
>
> movietexture=0;
>
> while(movietexture>=0)
>
> [movietexture] = Screen('GetMovieImage', win, movie, 0);
>
> if (movietexture>0)
> Screen('DrawTexture', win, movietexture);
> Screen('Flip', win);
> Screen('Close', movietexture);
> movietexture=0;
> end;
>
> [keyIsDown, secs, keyCode]=KbCheck;
> if (keyIsDown==1)
> if keyCode(KbName('ESCAPE'))
> droppedframes=Screen('PlayMovie', movie, 0, 0, 0);
> Screen('CloseMovie', movie);
> break;
> end;
> end;
> end;
>
> Screen('PlayMovie', movie, 0, 0, 0);
> Screen('CloseMovie', movie);
> end
>
>
> Whenever I press ESC to stop playback, it gives the error message that
> the movie handle does not exist. It does not have any problem when the
> same code is used after the display while loop (no error then). Any ideas?
>
> Thanks in advance,
>
> - Jeff
>
Ah, thanks Mario! I was worried it would be something embarassingly
easy like that :)

--- In psychtoolbox@yahoogroups.com, "Mario Kleiner"
<mario.kleiner@...> wrote:
>
> Simple: You close the movie in your if(kbName('EsCAPe...
> statement, then break out of the while loop, then try
> to stop/close the movie agan that's been closed already,
> so its handle is invalid --> error.
>
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "lejeph" <jloucks@> wrote:
> >
> > Hi all, I am having trouble with stopping movie playback using
> > Screen(PlayMovie). Here is the script I am using:
> >
> >
> > for i=1:ntrials;
> >
> > film=strcat
('/Users/jeph/Documents/Psychtoolbox_experiments/scam/movies/',char
> (moviename(i)));
> >
> > [movie] = Screen('OpenMovie', win, film);
> >
> > Screen('PlayMovie', movie, 1, 0, 1.0);
> >
> > movietexture=0;
> >
> > while(movietexture>=0)
> >
> > [movietexture] = Screen('GetMovieImage', win, movie, 0);
> >
> > if (movietexture>0)
> > Screen('DrawTexture', win, movietexture);
> > Screen('Flip', win);
> > Screen('Close', movietexture);
> > movietexture=0;
> > end;
> >
> > [keyIsDown, secs, keyCode]=KbCheck;
> > if (keyIsDown==1)
> > if keyCode(KbName('ESCAPE'))
> > droppedframes=Screen('PlayMovie', movie, 0, 0, 0);
> > Screen('CloseMovie', movie);
> > break;
> > end;
> > end;
> > end;
> >
> > Screen('PlayMovie', movie, 0, 0, 0);
> > Screen('CloseMovie', movie);
> > end
> >
> >
> > Whenever I press ESC to stop playback, it gives the error message
that
> > the movie handle does not exist. It does not have any problem
when the
> > same code is used after the display while loop (no error then).
Any ideas?
> >
> > Thanks in advance,
> >
> > - Jeff
> >
>