Media_player

The media_player plug-in plays back a video file. Many formats are supported, but the playback quality of certain formats varies. The recommended formats for now are DivX or XVid (avi) and Flash Video (flv). For successful playback of MPEG (mpg) and Windows Media (wmv) files, please make sure the files are not corrupt and the indices of keyframes are intact. If this is not the case, it will result in choppy playback and skipping audio. The following options are available:

Response collection

If you enter 'keypress' or 'mouseclick' as a duration, responses will be logged in the regular way. That is, the following variables will be set:

Custom event handling

If you want, you can override the duration setting and use your own code to handle keypress and mouseclick events, which should be entered in the edit field. The PyGame event is passed as 'event' and you can control playback by setting the the 'continue_playing' and 'self.paused' variables. For example, in order to pause playback when the spacebar is pressed and stop playback when a mousebutton is clicked, you enter:

if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
        self.paused = not self.paused
if event.type == pygame.MOUSEBUTTONDOWN:
        continue_playback = False

Please refer to the PyGame documentation for more information:

http://www.pygame.org/docs/ref/key.html

The number of the last played frame is also available under the variable: frame_no