diplomat.wx_gui.video_player.VideoPlayer

class diplomat.wx_gui.video_player.VideoPlayer(*args: Any, **kwargs: Any)[source]

Bases: Control

A video player for wx Widgets, Using cv2 for solid cross-platform video support. Can play video, but no audio.

__init__(parent, w_id=wx.ID_ANY, video_hdl: VideoCapture = None, crop_box: Tuple[int, int, int, int] | None = None, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BORDER_DEFAULT, validator=wx.DefaultValidator, name='VideoPlayer')[source]

Create a new VideoPlayer

Parameters:
  • parent – The wx Control Parent.

  • w_id – The wx ID.

  • video_hdl – The cv2 VideoCapture to play video from. One should avoid never manipulate the video capture once passed to this constructor, as the handle will be passed to another thread for fast video loading.

  • pos – The position of the widget.

  • size – The size of the widget.

  • style – The style of the widget.

  • validator – The widgets validator.

  • name – The name of the widget.

Methods

__init__(parent[, w_id, video_hdl, ...])

Create a new VideoPlayer

freeze()

Freeze the video player, immediately pausing the video and making it unresponsive to play/pause/stop commands, and also frame changing methods.

get_offset_count()

Get the current frame index we are at in the video.

get_total_frames()

Get the total number of frames in this video.

is_frozen()

Check whether this video is frozen.

is_playing()

Returns whether or not the video is currently playing.

move_back([amount])

Move backward a given amount of frames.

move_forward([amount])

Move forward a given amount of frames.

on_draw(dc)

Draws the widget.

on_paint(event)

Run on a paint event, redraws the widget.

pause()

Pause the video.

play()

Play the video.

set_offset_frames(value)

Set the current frame offset location into the video.

stop()

Stop the video.

unfreeze()

Unfreeze the video, allowing controls to work again.

Attributes

BACK_LOAD_AMT

BUFFER_SIZE

EVT_FRAME_CHANGE

EVT_PLAY_STATE_CHANGE

FrameChangeEvent

PlayStateChangeEvent

freeze()[source]

Freeze the video player, immediately pausing the video and making it unresponsive to play/pause/stop commands, and also frame changing methods.

get_offset_count()[source]

Get the current frame index we are at in the video.

Returns:

An integer, the frame offset.

get_total_frames()[source]

Get the total number of frames in this video.

Returns:

An integer being the total frame count of the video.

is_frozen() bool[source]

Check whether this video is frozen.

Returns:

True is this video is frozen and therefore will not respond to any play/pause/stop commands, or False otherwise.

is_playing() bool[source]

Returns whether or not the video is currently playing.

move_back(amount: int = 1)[source]

Move backward a given amount of frames.

Parameters:

amount – A non-negative integer. Being how many frames to move backward. Defaults to 1. Can be 0, does nothing if so.

move_forward(amount: int = 1)[source]

Move forward a given amount of frames.

Parameters:

amount – A non-negative integer. Being how many frames to move forward. Defaults to 1. Can be 0, does nothing if so.

on_draw(dc: wx.DC)[source]

Draws the widget.

Parameters:

dc – The wx DC to use for drawing.

on_paint(event)[source]

Run on a paint event, redraws the widget.

pause()[source]

Pause the video.

play()[source]

Play the video.

set_offset_frames(value: int)[source]

Set the current frame offset location into the video.

Parameters:

value – An integer index, being the frame to move to in the video.

stop()[source]

Stop the video.

unfreeze()[source]

Unfreeze the video, allowing controls to work again.