GstPlayer.Player

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GstPlayer.Player GstPlayer.Player Gst.Object->GstPlayer.Player

Subclasses:

None

Methods

Inherited:

Gst.Object (27), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

config_get_position_update_interval (config)

class

config_get_seek_accurate (config)

class

config_get_user_agent (config)

class

config_set_position_update_interval (config, interval)

class

config_set_seek_accurate (config, accurate)

class

config_set_user_agent (config, agent)

class

get_audio_streams (info)

class

get_subtitle_streams (info)

class

get_video_streams (info)

class

new (video_renderer, signal_dispatcher)

class

visualizations_free (viss)

class

visualizations_get ()

get_audio_video_offset ()

get_color_balance (type)

get_config ()

get_current_audio_track ()

get_current_subtitle_track ()

get_current_video_track ()

get_current_visualization ()

get_duration ()

get_media_info ()

get_multiview_flags ()

get_multiview_mode ()

get_mute ()

get_pipeline ()

get_position ()

get_rate ()

get_subtitle_uri ()

get_subtitle_video_offset ()

get_uri ()

get_video_snapshot (format, config)

get_volume ()

has_color_balance ()

pause ()

play ()

seek (position)

set_audio_track (stream_index)

set_audio_track_enabled (enabled)

set_audio_video_offset (offset)

set_color_balance (type, value)

set_config (config)

set_multiview_flags (flags)

set_multiview_mode (mode)

set_mute (val)

set_rate (rate)

set_subtitle_track (stream_index)

set_subtitle_track_enabled (enabled)

set_subtitle_uri (uri)

set_subtitle_video_offset (offset)

set_uri (uri)

set_video_track (stream_index)

set_video_track_enabled (enabled)

set_visualization (name)

set_visualization_enabled (enabled)

set_volume (val)

stop ()

Virtual Methods

Inherited:

Gst.Object (1), GObject.Object (7)

Properties

Inherited:

Gst.Object (2)

Name

Type

Flags

Short Description

audio-video-offset

int

r/w

The synchronisation offset between audio and video in nanoseconds

current-audio-track

GstPlayer.PlayerAudioInfo

r

Current audio track information

current-subtitle-track

GstPlayer.PlayerSubtitleInfo

r

Current audio subtitle information

current-video-track

GstPlayer.PlayerVideoInfo

r

Current video track information

duration

int

r

Duration

media-info

GstPlayer.PlayerMediaInfo

r

Current media information

mute

bool

r/w

Mute

pipeline

Gst.Element

r

GStreamer pipeline that is used

position

int

r

Current Position

rate

float

r/w

Playback rate

signal-dispatcher

GstPlayer.PlayerSignalDispatcher

w/co

Dispatcher for the signals to e.g. event loops

subtitle-video-offset

int

r/w

The synchronisation offset between text and video in nanoseconds

suburi

str

r/w

Current Subtitle URI

uri

str

r/w

Current URI

video-multiview-flags

GstVideo.VideoMultiviewFlags

r/w

Override details of the multiview frame layout

video-multiview-mode

GstVideo.VideoMultiviewFramePacking

r/w

Re-interpret a video stream as one of several frame-packed stereoscopic modes.

video-renderer

GstPlayer.PlayerVideoRenderer

r/w/co

Video renderer to use for rendering videos

volume

float

r/w

Volume

Signals

Inherited:

Gst.Object (1), GObject.Object (1)

Name

Short Description

buffering

duration-changed

end-of-stream

error

media-info-updated

mute-changed

position-updated

seek-done

state-changed

uri-loaded

video-dimensions-changed

volume-changed

warning

Fields

Inherited:

Gst.Object (1), GObject.Object (1)

Class Details

class GstPlayer.Player(**kwargs)
Bases:

Gst.Object

Abstract:

No

Structure:

GstPlayer.PlayerClass

Starting from GStreamer 1.20, application developers are strongly advised to migrate to #GstPlay. GstPlayer.Player will be deprecated in 1.20 and most likely removed by 1.24.

classmethod config_get_position_update_interval(config)
Parameters:

config (Gst.Structure) – a GstPlayer.Player configuration

Returns:

current position update interval in milliseconds

Return type:

int

New in version 1.10.

classmethod config_get_seek_accurate(config)
Parameters:

config (Gst.Structure) – a GstPlayer.Player configuration

Returns:

True if accurate seeking is enabled

Return type:

bool

New in version 1.12.

classmethod config_get_user_agent(config)
Parameters:

config (Gst.Structure) – a GstPlayer.Player configuration

Returns:

the configured agent, or None

Return type:

str or None

Return the user agent which has been configured using GstPlayer.Player.config_set_user_agent() if any.

New in version 1.10.

classmethod config_set_position_update_interval(config, interval)
Parameters:

set interval in milliseconds between two position-updated signals. pass 0 to stop updating the position.

New in version 1.10.

classmethod config_set_seek_accurate(config, accurate)
Parameters:

Enable or disable accurate seeking. When enabled, elements will try harder to seek as accurately as possible to the requested seek position. Generally it will be slower especially for formats that don’t have any indexes or timestamp markers in the stream.

If accurate seeking is disabled, elements will seek as close as the request position without slowing down seeking too much.

Accurate seeking is disabled by default.

New in version 1.12.

classmethod config_set_user_agent(config, agent)
Parameters:

Set the user agent to pass to the server if player needs to connect to a server during playback. This is typically used when playing HTTP or RTSP streams.

New in version 1.10.

classmethod get_audio_streams(info)
Parameters:

info (GstPlayer.PlayerMediaInfo) – a GstPlayer.PlayerMediaInfo

Returns:

A GLib.List of matching GstPlayer.PlayerAudioInfo.

Return type:

[GstPlayer.PlayerAudioInfo]

classmethod get_subtitle_streams(info)
Parameters:

info (GstPlayer.PlayerMediaInfo) – a GstPlayer.PlayerMediaInfo

Returns:

A GLib.List of matching GstPlayer.PlayerSubtitleInfo.

Return type:

[GstPlayer.PlayerSubtitleInfo]

classmethod get_video_streams(info)
Parameters:

info (GstPlayer.PlayerMediaInfo) – a GstPlayer.PlayerMediaInfo

Returns:

A GLib.List of matching GstPlayer.PlayerVideoInfo.

Return type:

[GstPlayer.PlayerVideoInfo]

classmethod new(video_renderer, signal_dispatcher)
Parameters:
Returns:

a new GstPlayer.Player instance

Return type:

GstPlayer.Player

Creates a new GstPlayer.Player instance that uses signal_dispatcher to dispatch signals to some event loop system, or emits signals directly if None is passed. See GstPlayer.PlayerGMainContextSignalDispatcher.new().

Video is going to be rendered by video_renderer, or if None is provided no special video set up will be done and some default handling will be performed.

This also initializes GStreamer via gst_init() on the first call if this didn’t happen before.

classmethod visualizations_free(viss)
Parameters:

viss (GstPlayer.PlayerVisualization) – a None terminated array of GstPlayer.PlayerVisualization to free

Frees a None terminated array of GstPlayer.PlayerVisualization.

classmethod visualizations_get()
Returns:

a None terminated array containing all available visualizations. Use GstPlayer.Player.visualizations_free() after usage.

Return type:

[GstPlayer.PlayerVisualization]

get_audio_video_offset()
Returns:

The current value of audio-video-offset in nanoseconds

Return type:

int

Retrieve the current value of audio-video-offset property

New in version 1.10.

get_color_balance(type)
Parameters:

type (GstPlayer.PlayerColorBalanceType) – GstPlayer.PlayerColorBalanceType

Returns:

The current value of type, between [0,1]. In case of error -1 is returned.

Return type:

float

Retrieve the current value of the indicated type.

get_config()
Returns:

a copy of the current configuration of self. Use Gst.Structure.free() after usage or GstPlayer.Player.set_config().

Return type:

Gst.Structure

Get a copy of the current configuration of the player. This configuration can either be modified and used for the GstPlayer.Player.set_config() call or it must be freed after usage.

New in version 1.10.

get_current_audio_track()
Returns:

current audio track.

The caller should free it with GObject.Object.unref()

Return type:

GstPlayer.PlayerAudioInfo or None

A Function to get current audio GstPlayer.PlayerAudioInfo instance.

get_current_subtitle_track()
Returns:

current subtitle track.

The caller should free it with GObject.Object.unref()

Return type:

GstPlayer.PlayerSubtitleInfo or None

A Function to get current subtitle GstPlayer.PlayerSubtitleInfo instance.

get_current_video_track()
Returns:

current video track.

The caller should free it with GObject.Object.unref()

Return type:

GstPlayer.PlayerVideoInfo or None

A Function to get current video GstPlayer.PlayerVideoInfo instance.

get_current_visualization()
Returns:

Name of the currently enabled visualization. GLib.free() after usage.

Return type:

str or None

get_duration()
Returns:

the duration of the currently-playing media stream, in nanoseconds.

Return type:

int

Retrieves the duration of the media stream that self represents.

get_media_info()
Returns:

media info instance.

The caller should free it with GObject.Object.unref()

Return type:

GstPlayer.PlayerMediaInfo or None

A Function to get the current media info GstPlayer.PlayerMediaInfo instance.

get_multiview_flags()
Returns:

The current value of type, Default: 0x00000000 “none

Return type:

GstVideo.VideoMultiviewFlags

Retrieve the current value of the indicated type.

New in version 1.10.

get_multiview_mode()
Returns:

The current value of type, Default: -1 “none”

Return type:

GstVideo.VideoMultiviewFramePacking

Retrieve the current value of the indicated type.

New in version 1.10.

get_mute()
Returns:

True if the currently-playing stream is muted.

Return type:

bool

get_pipeline()
Returns:

The internal playbin instance.

The caller should free it with GObject.Object.unref()

Return type:

Gst.Element

get_position()
Returns:

the absolute position time, in nanoseconds, of the currently-playing stream.

Return type:

int

get_rate()
Returns:

current playback rate

Return type:

float

get_subtitle_uri()
Returns:

URI of the current external subtitle. GLib.free() after usage.

Return type:

str or None

current subtitle URI

get_subtitle_video_offset()
Returns:

The current value of subtitle-video-offset in nanoseconds

Return type:

int

Retrieve the current value of subtitle-video-offset property

New in version 1.16.

get_uri()
Returns:

a string containing the URI of the currently-playing stream. GLib.free() after usage.

Return type:

str or None

Gets the URI of the currently-playing stream.

get_video_snapshot(format, config)
Parameters:
Returns:

Current video snapshot sample or None on failure

Return type:

Gst.Sample or None

Get a snapshot of the currently selected video stream, if any. The format can be selected with format and optional configuration is possible with config Currently supported settings are:

New in version 1.12.

get_volume()
Returns:

the volume as percentage between 0 and 1.

Return type:

float

Returns the current volume level, as a percentage between 0 and 1.

has_color_balance()
Returns:

True if self has color balance support. Otherwise, False.

Return type:

bool

Checks whether the self has color balance support available.

pause()

Pauses the current stream.

play()

Request to play the loaded stream.

seek(position)
Parameters:

position (int) – position to seek in nanoseconds

Seeks the currently-playing stream to the absolute position time in nanoseconds.

set_audio_track(stream_index)
Parameters:

stream_index (int) – stream index

Returns:

True or False

Sets the audio track stream_idex.

Return type:

bool

set_audio_track_enabled(enabled)
Parameters:

enabled (bool) – True or False

Enable or disable the current audio track.

set_audio_video_offset(offset)
Parameters:

offset (int) – #gint64 in nanoseconds

Sets audio-video-offset property by value of offset

New in version 1.10.

set_color_balance(type, value)
Parameters:

Sets the current value of the indicated channel type to the passed value.

set_config(config)
Parameters:

config (Gst.Structure) – a Gst.Structure

Returns:

True when the configuration could be set.

Return type:

bool

Set the configuration of the player. If the player is already configured, and the configuration haven’t change, this function will return True. If the player is not in the GstPlayer.PlayerState.STOPPED, this method will return False and active configuration will remain.

config is a Gst.Structure that contains the configuration parameters for the player.

This function takes ownership of config.

New in version 1.10.

set_multiview_flags(flags)
Parameters:

flags (GstVideo.VideoMultiviewFlags) – The new value for the type

Sets the current value of the indicated mode type to the passed value.

New in version 1.10.

set_multiview_mode(mode)
Parameters:

mode (GstVideo.VideoMultiviewFramePacking) – The new value for the type

Sets the current value of the indicated mode type to the passed value.

New in version 1.10.

set_mute(val)
Parameters:

val (bool) – Mute state the should be set

True if the currently-playing stream should be muted.

set_rate(rate)
Parameters:

rate (float) – playback rate

Playback at specified rate

set_subtitle_track(stream_index)
Parameters:

stream_index (int) – stream index

Returns:

True or False

Sets the subtitle stack stream_index.

Return type:

bool

set_subtitle_track_enabled(enabled)
Parameters:

enabled (bool) – True or False

Enable or disable the current subtitle track.

set_subtitle_uri(uri)
Parameters:

uri (str or None) – subtitle URI

Sets the external subtitle URI. This should be combined with a call to GstPlayer.Player.set_subtitle_track_enabled(self, True) so the subtitles are actually rendered.

set_subtitle_video_offset(offset)
Parameters:

offset (int) – #gint64 in nanoseconds

Sets subtitle-video-offset property by value of offset

New in version 1.16.

set_uri(uri)
Parameters:

uri (str or None) – next URI to play.

Sets the next URI to play.

set_video_track(stream_index)
Parameters:

stream_index (int) – stream index

Returns:

True or False

Sets the video track stream_index.

Return type:

bool

set_video_track_enabled(enabled)
Parameters:

enabled (bool) – True or False

Enable or disable the current video track.

set_visualization(name)
Parameters:

name (str or None) – visualization element obtained from GstPlayer.Player.visualizations_get()

Returns:

True if the visualizations was set correctly. Otherwise, False.

Return type:

bool

set_visualization_enabled(enabled)
Parameters:

enabled (bool) – True or False

Enable or disable the visualization.

set_volume(val)
Parameters:

val (float) – the new volume level, as a percentage between 0 and 1

Sets the volume level of the stream as a percentage between 0 and 1.

This volume is a linear factor. For showing the volume in a GUI it might make sense to first convert from a different format. Volume sliders should usually use a cubic volume. See GstAudio.StreamVolume.convert_volume().

stop()

Stops playing the current stream and resets to the first position in the stream.

Signal Details

GstPlayer.Player.signals.buffering(player, object)
Signal Name:

buffering

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.duration_changed(player, object)
Signal Name:

duration-changed

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.end_of_stream(player)
Signal Name:

end-of-stream

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

player (GstPlayer.Player) – The object which received the signal

GstPlayer.Player.signals.error(player, object)
Signal Name:

error

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.media_info_updated(player, object)
Signal Name:

media-info-updated

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.mute_changed(player)
Signal Name:

mute-changed

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

player (GstPlayer.Player) – The object which received the signal

GstPlayer.Player.signals.position_updated(player, object)
Signal Name:

position-updated

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.seek_done(player, object)
Signal Name:

seek-done

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.state_changed(player, object)
Signal Name:

state-changed

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.uri_loaded(player, object)
Signal Name:

uri-loaded

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.video_dimensions_changed(player, object, p0)
Signal Name:

video-dimensions-changed

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:
GstPlayer.Player.signals.volume_changed(player)
Signal Name:

volume-changed

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

player (GstPlayer.Player) – The object which received the signal

GstPlayer.Player.signals.warning(player, object)
Signal Name:

warning

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

Property Details

GstPlayer.Player.props.audio_video_offset
Name:

audio-video-offset

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The synchronisation offset between audio and video in nanoseconds

GstPlayer.Player.props.current_audio_track
Name:

current-audio-track

Type:

GstPlayer.PlayerAudioInfo

Default Value:

None

Flags:

READABLE

Current audio track information

GstPlayer.Player.props.current_subtitle_track
Name:

current-subtitle-track

Type:

GstPlayer.PlayerSubtitleInfo

Default Value:

None

Flags:

READABLE

Current audio subtitle information

GstPlayer.Player.props.current_video_track
Name:

current-video-track

Type:

GstPlayer.PlayerVideoInfo

Default Value:

None

Flags:

READABLE

Current video track information

GstPlayer.Player.props.duration
Name:

duration

Type:

int

Default Value:

18446744073709551615

Flags:

READABLE

Duration

GstPlayer.Player.props.media_info
Name:

media-info

Type:

GstPlayer.PlayerMediaInfo

Default Value:

None

Flags:

READABLE

Current media information

GstPlayer.Player.props.mute
Name:

mute

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Mute

GstPlayer.Player.props.pipeline
Name:

pipeline

Type:

Gst.Element

Default Value:

None

Flags:

READABLE

GStreamer pipeline that is used

GstPlayer.Player.props.position
Name:

position

Type:

int

Default Value:

18446744073709551615

Flags:

READABLE

Current Position

GstPlayer.Player.props.rate
Name:

rate

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

Playback rate

GstPlayer.Player.props.signal_dispatcher
Name:

signal-dispatcher

Type:

GstPlayer.PlayerSignalDispatcher

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

Dispatcher for the signals to e.g. event loops

GstPlayer.Player.props.subtitle_video_offset
Name:

subtitle-video-offset

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The synchronisation offset between text and video in nanoseconds

GstPlayer.Player.props.suburi
Name:

suburi

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

Current Subtitle URI

GstPlayer.Player.props.uri
Name:

uri

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

Current URI

GstPlayer.Player.props.video_multiview_flags
Name:

video-multiview-flags

Type:

GstVideo.VideoMultiviewFlags

Default Value:

GstVideo.VideoMultiviewFlags.NONE

Flags:

READABLE, WRITABLE

Override details of the multiview frame layout

GstPlayer.Player.props.video_multiview_mode
Name:

video-multiview-mode

Type:

GstVideo.VideoMultiviewFramePacking

Default Value:

GstVideo.VideoMultiviewFramePacking.NONE

Flags:

READABLE, WRITABLE

Re-interpret a video stream as one of several frame-packed stereoscopic modes.

GstPlayer.Player.props.video_renderer
Name:

video-renderer

Type:

GstPlayer.PlayerVideoRenderer

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Video renderer to use for rendering videos

GstPlayer.Player.props.volume
Name:

volume

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

Volume