core.generator.ui.contents.video_content

File:

EuljiroWorship/core/generator/ui/contents/video_content.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

UI content widget for editing “video”-style slides.

This module defines core.generator.ui.contents.video_content.VideoContent, a QWidget that allows users to select a video file, preview it, and associate it with caption text for use in video-based slides. Selected videos are copied into a local html/img/ directory for reliable access by overlay HTML files.

In this slide style, the headline field is repurposed to store the relative video path, while the caption field is used as accompanying text displayed alongside the video.

The widget integrates with core.generator.utils.slide_input_submitter.SlideInputSubmitter to support automatic submission and synchronization with the parent generator window.

class core.generator.ui.contents.video_content.VideoContent(*args, **kwargs)[source]

Bases: QWidget

Content editor widget for “video” style slides.

This widget supports selecting a local video file, copying it into the overlay asset directory (./html/img), previewing it using Qt Multimedia, and exporting the selection as slide data.

Slide-data mapping:

  • caption: optional text shown alongside the media

  • headline: relative video path used by the overlay (e.g., "img/foo.mp4")

The preview player resolves stored relative paths against ./html/ so that values produced by copy_to_img_folder() can be previewed consistently.

Parameters:
  • caption (str)

  • headline (str)

caption

Initial caption text provided at construction time.

Type:

str

headline

Relative video path stored in slide data (e.g., "img/foo.mp4").

Type:

str

generator_window

Reference to the generator main window. Used by the input submitter to synchronize and auto-save slide edits.

player

Qt Multimedia player used for in-widget preview playback. Initialized in _init_player().

Type:

QMediaPlayer | None

audio

Audio output sink for preview playback. Attached to player.

Type:

QAudioOutput | None

video_widget

Video output widget used to render preview frames.

Type:

QVideoWidget | None

headline_edit

Input field holding the relative video path (stored in headline).

Type:

QLineEdit

caption_edit

Input field holding the caption text.

Type:

QLineEdit

video_button

Button that opens a file picker to select a video.

Type:

QPushButton

preview_label

Label showing the selected filename or status messages (e.g., “비디오 로딩 실패”).

Type:

QLabel

play_button

Starts preview playback.

Type:

QPushButton

pause_button

Pauses preview playback.

Type:

QPushButton

stop_button

Stops preview playback and resets position.

Type:

QPushButton

submitter

Auto-submit helper that produces export-ready slide payloads using build_video_slide().

Type:

SlideInputSubmitter

__init__(parent, generator_window, caption='', headline='')[source]

Initialize the video content editor.

Parameters:
  • parent (QWidget) – Parent widget container.

  • generator_window – Reference to the generator window, used for submitting slide data and enabling auto-save behavior.

  • caption (str) – Initial caption text associated with the video.

  • headline (str) – Initial video path (stored in the headline field).

Returns:

None

build_ui()[source]

Construct the UI elements for editing a video slide.

Builds input fields for caption and video path, a button for selecting a video file, and a video preview area. Registers the input fields with core.generator.utils.slide_input_submitter.SlideInputSubmitter to enable automatic submission.

Returns:

None

_init_player()[source]

Initialize QMediaPlayer for in-widget preview.

Returns:

None

select_video()[source]

Prompt the user to select a video file and register it for slide use.

The selected video is copied into the local html/img directory and its relative path is stored in the headline field.

Returns:

None

copy_to_img_folder(source_path)[source]

Copy the selected video file into the local image directory (html/img).

If the destination directory does not exist, it is created. If the file already exists at the destination, it is not copied again.

Parameters:

source_path (str) – Absolute path to the source video file.

Returns:

Relative path for overlay HTML usage, e.g. img/example.mp4.

Return type:

str

Raises:

OSError – If the file cannot be copied or the destination directory cannot be created.

_load_preview_from_absolute_path(abs_path)[source]

Load preview video into QMediaPlayer from an absolute file path.

Parameters:

abs_path (str) – Absolute file path.

Returns:

None

_load_preview_from_relative_path(rel_path)[source]

Load preview video into QMediaPlayer from a relative path like img/foo.mp4.

This resolves it against ./html/ to match the copy destination.

Parameters:

rel_path (str) – Relative path stored in slide data.

Returns:

None

play_preview()[source]

Start playing the preview video.

Returns:

None

pause_preview()[source]

Pause the preview video.

Returns:

None

stop_preview()[source]

Stop the preview video.

Returns:

None

build_video_slide()[source]

Conditionally generate video slide data.

If no video path has been selected, no slide data is generated.

Returns:

Slide data dictionary if a video is selected; otherwise, None.

Return type:

dict | None

get_slide_data()[source]

Generate the slide data dictionary for a video slide.

Returns:

Dictionary representing the video slide:

  • style

  • caption

  • headline (relative video path, e.g., img/foo.mp4)

Return type:

dict

set_content(data)[source]

Restore saved video slide data into the editor UI.

Populates caption and video path fields and attempts to load preview.

Parameters:

data (dict) – Slide data dictionary containing caption and video path.

Returns:

None