expyfun.visual.Video

class expyfun.visual.Video(ec, file_name, pos=(0, 0), units='norm', scale=1.0, center=True, visible=True)[source]

Read video file and draw it to the screen.

Parameters:
ecinstance of expyfun.ExperimentController
file_namestr

the video file path

posarray-like

2-element array-like with X, Y elements.

unitsstr

Units to use for the position. See check_units for options.

scalefloat | str

The scale factor. 1 is native size (pixel-to-pixel), 2 is twice as large, etc. If scale is a string, it must be either 'fill' (which ensures the entire ExperimentController window is covered by the video, at the expense of some parts of the video potentially being offscreen), or 'fit' (which scales maximally while ensuring none of the video is offscreen, and may result in letterboxing or pillarboxing).

centerbool

If False, the elements of pos specify the position of the lower left corner of the video frame; otherwise they position the center of the frame.

visiblebool

Whether to show the video when initialized. Can be toggled later using Video.set_visible method.

Notes

This is a somewhat pared-down implementation of video playback. Looping is not available, and the audio stream from the video file is discarded. Timing of individual frames is relegated to the pyglet media player’s internal clock. Recommended for use only in paradigms where the relative timing of audio and video are unimportant (e.g., if the video is merely entertainment for the participant during a passive auditory task).

draw()[source]

Draw the video texture to the screen buffer.

pause()[source]

Halt video playback.

Returns:
timefloat

The timestamp (on the parent ExperimentController timeline) at which pause() was called.

play(auto_draw=True)[source]

Play video from current position.

Parameters:
auto_drawbool

If True, add self.draw to ec.on_every_flip.

Returns:
timefloat

The timestamp (on the parent ExperimentController timeline) at which play() was called.

set_pos(pos, units='norm', center=True)[source]

Set video position.

Parameters:
posarray-like

2-element array-like with X, Y elements.

unitsstr

Units to use for the position. See check_units for options.

centerbool

If False, the elements of pos specify the position of the lower left corner of the video frame; otherwise they position the center of the frame.

set_scale(scale=1.0)[source]

Set video scale.

Parameters:
scalefloat | str

The scale factor. 1 is native size (pixel-to-pixel), 2 is twice as large, etc. If scale is a string, it must be either 'fill' (which ensures the entire ExperimentController window is covered by the video, at the expense of some parts of the video potentially being offscreen), or 'fit' (which scales maximally while ensuring none of the video is offscreen, which may result in letterboxing).

set_visible(show, flip=False)[source]

Show/hide the video frame.

Parameters:
showbool

Show or hide.

flipbool

If True, flip after showing or hiding.