Skip to content

MediaPlayer

Qt Base Class: QMediaPlayer

Signature: QMediaPlayer(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QMediaPlayer
PySide6.QtMultimedia
QMediaPlayer(self, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

⋔ Inheritance diagram

graph TD
  1473573991952["multimedia.MediaPlayer"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473573976336["QtMultimedia.QMediaPlayer"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299815024 --> 1473573991952
  140713234304496 --> 1473299815024
  1473573976336 --> 1473573991952
  1473288842240 --> 1473573976336
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ObjectMixin, QMediaPlayer

Source code in prettyqt\multimedia\mediaplayer.py
class MediaPlayer(core.ObjectMixin, QtMultimedia.QMediaPlayer):
    def set_source_device(
        self, device: core.QIODevice, url: datatypes.UrlType | None = None
    ):
        url = datatypes.to_local_url(url)
        self.setSourceDevice(device, url)

    def set_source(self, url: datatypes.UrlType):
        url = datatypes.to_local_url(url)
        self.setSource(url)

    def get_source(self) -> core.Url | None:
        url = self.source()
        return core.Url(url) if url.isValid() else None

    def get_playback_state(self) -> PlaybackStateStr:
        """Return current playback state.

        Returns:
            playback state
        """
        return PLAYBACK_STATE.inverse[self.playbackState()]

    def get_media_status(self) -> MediaStatusStr:
        """Return current media status.

        Returns:
            media status
        """
        return MEDIA_STATUS.inverse[self.mediaStatus()]

    def get_error(self) -> ErrorStr:
        """Return error type.

        Returns:
            error type
        """
        return ERROR.inverse[self.error()]

get_error() -> ErrorStr

Return error type.

Source code in prettyqt\multimedia\mediaplayer.py
def get_error(self) -> ErrorStr:
    """Return error type.

    Returns:
        error type
    """
    return ERROR.inverse[self.error()]

get_media_status() -> MediaStatusStr

Return current media status.

Source code in prettyqt\multimedia\mediaplayer.py
def get_media_status(self) -> MediaStatusStr:
    """Return current media status.

    Returns:
        media status
    """
    return MEDIA_STATUS.inverse[self.mediaStatus()]

get_playback_state() -> PlaybackStateStr

Return current playback state.

Source code in prettyqt\multimedia\mediaplayer.py
def get_playback_state(self) -> PlaybackStateStr:
    """Return current playback state.

    Returns:
        playback state
    """
    return PLAYBACK_STATE.inverse[self.playbackState()]

⌗ Property table

Qt Property Type Doc
objectName QString
source QUrl
duration qlonglong
position qlonglong
bufferProgress float
hasAudio bool
hasVideo bool
seekable bool
playing bool
playbackRate double
loops int
playbackState QMediaPlayer::PlaybackState
mediaStatus QMediaPlayer::MediaStatus
metaData QMediaMetaData
error QMediaPlayer::Error
errorString QString
videoOutput QObject
audioOutput QAudioOutput
audioTracks QList
videoTracks QList
subtitleTracks QList
activeAudioTrack int
activeVideoTrack int
activeSubtitleTrack int