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 entireExperimentController
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 ofpos
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.
- Attributes:
- dt
- duration
- finished
- frame_rate
- height
- playing
- position
- scale
- source_height
- source_width
- time
- time_offset
- width
Methods
draw
()Draw the video texture to the screen buffer.
pause
()Halt video playback.
play
([auto_draw])Play video from current position.
set_pos
(pos[, units, center])Set video position.
set_scale
([scale])Set video scale.
set_visible
(show[, flip])Show/hide the video frame.
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).
- pause()[source]#
Halt video playback.
- Returns:
- timefloat
The timestamp (on the parent
ExperimentController
timeline) at whichpause()
was called.
- play(auto_draw=True)[source]#
Play video from current position.
- Parameters:
- auto_drawbool
If True, add
self.draw
toec.on_every_flip
.
- Returns:
- timefloat
The timestamp (on the parent
ExperimentController
timeline) at whichplay()
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 ofpos
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 entireExperimentController
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).