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, zoom_config: ZoomConfig | 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.

  • crop_box – Tuple of ints, x, y, width, height, being the area of the video to show instead of the entire video. if set to None, just shows the entire video…

  • 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

EVT_FRAME_CHANGE

EVT_PLAY_STATE_CHANGE

FrameChangeEvent

MAX_FAST_FORWARD_MODE

PlayStateChangeEvent

video_transform

__del__()[source]

Delete this video player, deleting its video reading thread.

_on_timer(event, trigger_run=True)[source]

PRIVATE: Executed whenever a timer event occurs, which triggers a video frame update if the video is playing.

_push_time_change_event()[source]

PRIVATE: Used to specify how long the event should

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.