Video utilities

cv2PySide6.videoutil provides utility classes for running the video.

class cv2PySide6.videoutil.ClickableSlider(*args: Any, **kwargs: Any)[source]

Bases: QSlider

QSlider whose groove can be clicked to move to position.

class cv2PySide6.videoutil.MediaController(*args: Any, **kwargs: Any)[source]

Bases: QWidget

Widget to control QMediaPlayer.

This controller can change the playback state and media position by playButton(), stopButton(), and slider().

setPlayer() sets the player to be controlled by this widget.

slider() ClickableSlider[source]

Slider to change the media position.

playButton() PySide6.QtWidgets.QPushButton[source]

Button to play and pause the media.

stopButton() PySide6.QtWidgets.QPushButton[source]

Button to stop the media.

player() Optional[PySide6.QtMultimedia.QMediaPlayer][source]

Media player which is controlled by self.

onPlayButtonClicked()

Play or pause player().

onStopButtonClicked()

Stop player().

onSliderPress()

If the media was playing, pause and move to the pressed position.

onSliderMove(position: int)

Move the media to current slider position.

onSliderRelease()

If the media was paused by slider press, play the media.

setPlayer(player: Optional[PySide6.QtMultimedia.QMediaPlayer])[source]

Set player() and connect the signals.

connectPlayer(player: PySide6.QtMultimedia.QMediaPlayer)[source]

Connect signals and slots with player.

disconnectPlayer(player: PySide6.QtMultimedia.QMediaPlayer)[source]

Disconnect signals and slots with player.

onMediaDurationChange(duration: int)

Set the slider range to media duration.

onMediaPositionChange(position: int)

Update the slider position to video position.

onPlaybackStateChange(state: PySide6.QtMultimedia.QMediaPlayer.PlaybackState)

Switch the play icon and pause icon by state.