GstPlay.Play¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The synchronisation offset between audio and video in nanoseconds |
||
r |
Current audio track information |
||
r |
Current audio subtitle information |
||
r |
Current video track information |
||
r |
Duration |
||
r |
Current media information |
||
r/w |
Mute |
||
r |
GStreamer pipeline that is used |
||
r |
Current Position |
||
r/w |
Playback rate |
||
r/w |
The synchronisation offset between text and video in nanoseconds |
||
r/w |
Current Subtitle URI |
||
r/w |
Current URI |
||
r/w |
Override details of the multiview frame layout |
||
r/w |
Re-interpret a video stream as one of several frame-packed stereoscopic modes. |
||
r/w |
Video renderer to use for rendering videos |
||
r/w |
Volume |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GstPlay.Play(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The goal of the
GstPlay.Play
library is to ease the integration of multimedia playback features in applications. Thus, if you need to build a media player from the ground-up,GstPlay.Play
provides the features you will most likely need.An example player is available in gst-examples/playback/player/gst-play/.
Internally the
GstPlay.Play
makes use of theplaybin3
element. The legacyplaybin2
can be selected if theGST_PLAY_USE_PLAYBIN3=0
environment variable has been set.**Important note**: If your application relies on the
Gst.Bus
to get notifications fromGstPlay.Play
, you need to add some explicit clean-up code in order to prevent theGstPlay.Play
object from leaking. See below for the details. If you use theGstPlay.PlaySignalAdapter
, no special clean-up is required.When the
GstPlay.PlaySignalAdapter
is not used, theGst.Bus
owned byGstPlay.Play
should be set to flushing state before any attempt to drop the last reference of theGstPlay.Play
object. An example in C:``c¶
GstBus *bus = gst_play_get_message_bus (player); gst_bus_set_flushing (bus, TRUE); gst_object_unref (bus); gst_object_unref (player); ``
The messages managed by the player contain a reference to itself, and if the bus watch is just removed together with dropping the player then the bus will simply keep them around forever (and the bus never goes away because the player has a strong reference to it, so there’s a reference cycle as long as there are messages). Setting the bus to flushing state forces it to get rid of its queued messages, thus breaking any possible reference cycle.
New in version 1.20.
- classmethod config_get_pipeline_dump_in_error_details(config)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configuration- Returns:
True
if pipeline dumps are included inGstPlay.Play
error message details.- Return type:
New in version 1.24.
- classmethod config_get_position_update_interval(config)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configuration- Returns:
current position update interval in milliseconds
- Return type:
New in version 1.20.
- classmethod config_get_seek_accurate(config)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configuration- Returns:
True
if accurate seeking is enabled- Return type:
New in version 1.20.
- classmethod config_get_user_agent(config)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configuration- Returns:
the configured agent, or
None
- Return type:
Return the user agent which has been configured using
GstPlay.Play.config_set_user_agent
() if any.New in version 1.20.
- classmethod config_set_pipeline_dump_in_error_details(config, value)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configurationvalue (
bool
) – Include pipeline dumps in error details, or not.
When enabled, the error message emitted by
GstPlay.Play
will include a pipeline dump (in Graphviz DOT format) in the error detailsGst.Structure
. The field name ispipeline-dump
.This option is disabled by default.
New in version 1.24.
- classmethod config_set_position_update_interval(config, interval)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configurationinterval (
int
) – interval in ms
Set desired interval in milliseconds between two position-updated messages. Pass 0 to stop updating the position.
New in version 1.20.
- classmethod config_set_seek_accurate(config, accurate)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configurationaccurate (
bool
) – accurate seek or not
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.20.
- classmethod config_set_user_agent(config, agent)¶
- Parameters:
config (
Gst.Structure
) – aGstPlay.Play
configuration
Set the user agent to pass to the server if play needs to connect to a server during playback. This is typically used when playing HTTP or RTSP streams.
New in version 1.20.
- classmethod get_audio_streams(info)¶
- Parameters:
info (
GstPlay.PlayMediaInfo
) – aGstPlay.PlayMediaInfo
- Returns:
A
GLib.List
of matchingGstPlay.PlayAudioInfo
.- Return type:
New in version 1.20.
- classmethod get_subtitle_streams(info)¶
- Parameters:
info (
GstPlay.PlayMediaInfo
) – aGstPlay.PlayMediaInfo
- Returns:
A
GLib.List
of matchingGstPlay.PlaySubtitleInfo
.- Return type:
New in version 1.20.
- classmethod get_video_streams(info)¶
- Parameters:
info (
GstPlay.PlayMediaInfo
) – aGstPlay.PlayMediaInfo
- Returns:
A
GLib.List
of matchingGstPlay.PlayVideoInfo
.- Return type:
New in version 1.20.
- classmethod is_play_message(msg)¶
- Parameters:
msg (
Gst.Message
) – AGst.Message
- Returns:
A
bool
indicating whether the passed message represents aGstPlay.Play
message or not.- Return type:
New in version 1.20.
- classmethod new(video_renderer)¶
- Parameters:
video_renderer (
GstPlay.PlayVideoRenderer
orNone
) –GstPlay.PlayVideoRenderer
to use- Returns:
a new
GstPlay.Play
instance- Return type:
Creates a new
GstPlay.Play
instance.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.New in version 1.20.
- classmethod visualizations_free(viss)¶
- Parameters:
viss (
GstPlay.PlayVisualization
) – aNone
terminated array ofGstPlay.PlayVisualization
to free
Frees a
None
terminated array ofGstPlay.PlayVisualization
.New in version 1.20.
- classmethod visualizations_get()¶
- Returns:
a
None
terminated array containing all available visualizations. UseGstPlay.Play.visualizations_free
() after usage.- Return type:
New in version 1.20.
- get_audio_video_offset()¶
- Returns:
The current value of audio-video-offset in nanoseconds
- Return type:
Retrieve the current value of audio-video-offset property
New in version 1.20.
- get_color_balance(type)¶
- Parameters:
type (
GstPlay.PlayColorBalanceType
) –GstPlay.PlayColorBalanceType
- Returns:
The current value of type, between [0,1]. In case of error -1 is returned.
- Return type:
Retrieve the current value of the indicated type.
New in version 1.20.
- get_config()¶
- Returns:
a copy of the current configuration of self. Use
Gst.Structure.free
() after usage orGstPlay.Play.set_config
().- Return type:
Get a copy of the current configuration of the play. This configuration can either be modified and used for the
GstPlay.Play.set_config
() call or it must be freed after usage.New in version 1.20.
- get_current_audio_track()¶
- Returns:
current audio track.
The caller should free it with
GObject.Object.unref
()- Return type:
A Function to get current audio
GstPlay.PlayAudioInfo
instance.New in version 1.20.
- get_current_subtitle_track()¶
- Returns:
current subtitle track.
The caller should free it with
GObject.Object.unref
()- Return type:
A Function to get current subtitle
GstPlay.PlaySubtitleInfo
instance.New in version 1.20.
- get_current_video_track()¶
- Returns:
current video track.
The caller should free it with
GObject.Object.unref
()- Return type:
A Function to get current video
GstPlay.PlayVideoInfo
instance.New in version 1.20.
- get_current_visualization()¶
- Returns:
Name of the currently enabled visualization.
GLib.free
() after usage.- Return type:
New in version 1.20.
- get_duration()¶
- Returns:
the duration of the currently-playing media stream, in nanoseconds.
- Return type:
Retrieves the duration of the media stream that self represents.
New in version 1.20.
- get_media_info()¶
- Returns:
media info instance.
The caller should free it with
GObject.Object.unref
()- Return type:
A Function to get the current media info
GstPlay.PlayMediaInfo
instance.New in version 1.20.
- get_message_bus()¶
- Returns:
The play message bus instance
- Return type:
GstPlay.Play
API exposes aGst.Bus
instance which purpose is to provide data structures representing play-internal events in form ofGst.Message
s of typeGst.MessageType.APPLICATION
.Each message carries a “play-message” field of type
GstPlay.PlayMessage
. Further fields of the message data are specific to each possible value of that enumeration.Applications can consume the messages asynchronously within their own event-loop / UI-thread etc. Note that in case the application does not consume the messages, the bus will accumulate these internally and eventually fill memory. To avoid that, the bus has to be set “flushing”.
New in version 1.20.
- get_multiview_flags()¶
- Returns:
The current value of type, Default: 0x00000000 “none
- Return type:
Retrieve the current value of the indicated type.
New in version 1.20.
- get_multiview_mode()¶
- Returns:
The current value of type, Default: -1 “none”
- Return type:
Retrieve the current value of the indicated type.
New in version 1.20.
- get_mute()¶
-
New in version 1.20.
- get_pipeline()¶
- Returns:
The internal playbin instance.
The caller should free it with
GObject.Object.unref
()- Return type:
New in version 1.20.
- get_position()¶
- Returns:
the absolute position time, in nanoseconds, of the currently-playing stream.
- Return type:
New in version 1.20.
- get_subtitle_uri()¶
-
Current subtitle URI
New in version 1.20.
- get_subtitle_video_offset()¶
- Returns:
The current value of subtitle-video-offset in nanoseconds
- Return type:
Retrieve the current value of subtitle-video-offset property
New in version 1.20.
- get_uri()¶
- Returns:
a string containing the URI of the currently-playing stream.
GLib.free
() after usage.- Return type:
Gets the URI of the currently-playing stream.
New in version 1.20.
- get_video_snapshot(format, config)¶
- Parameters:
format (
GstPlay.PlaySnapshotFormat
) – output format of the video snapshotconfig (
Gst.Structure
orNone
) – Additional configuration
- Returns:
Current video snapshot sample or
None
on failure- Return type:
Gst.Sample
orNone
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:
width, height of type
GObject.TYPE_INT
pixel-aspect-ratio of type GST_TYPE_FRACTION Except for
GstPlay.PlaySnapshotFormat.RAW_NATIVE
format, if no config is set, pixel-aspect-ratio would be 1/1
New in version 1.20.
- get_volume()¶
- Returns:
the volume as percentage between 0 and 1.
- Return type:
Returns the current volume level, as a percentage between 0 and 1.
New in version 1.20.
- has_color_balance()¶
-
Checks whether the self has color balance support available.
New in version 1.20.
- pause()¶
Pauses the current stream.
New in version 1.20.
- play()¶
Request to play the loaded stream.
New in version 1.20.
- seek(position)¶
- Parameters:
position (
int
) – position to seek in nanoseconds
Seeks the currently-playing stream to the absolute position time in nanoseconds.
New in version 1.20.
- set_audio_track(stream_index)¶
- Parameters:
stream_index (
int
) – stream index- Returns:
-
Sets the audio track stream_index.
- Return type:
New in version 1.20.
Deprecated since version 1.26: Use
GstPlay.Play.set_audio_track_id
() instead.
- set_audio_track_enabled(enabled)¶
-
Enable or disable the current audio track.
New in version 1.20.
- set_audio_track_id(stream_id)¶
- Parameters:
- Returns:
-
Sets the audio track stream_id.
- Return type:
New in version 1.26.
- set_audio_video_offset(offset)¶
- Parameters:
offset (
int
) – #gint64 in nanoseconds
Sets audio-video-offset property by value of offset
New in version 1.20.
- set_color_balance(type, value)¶
- Parameters:
type (
GstPlay.PlayColorBalanceType
) –GstPlay.PlayColorBalanceType
value (
float
) – The new value for the type, ranged [0,1]
Sets the current value of the indicated channel type to the passed value.
New in version 1.20.
- set_config(config)¶
- Parameters:
config (
Gst.Structure
) – aGst.Structure
- Returns:
True
when the configuration could be set.- Return type:
Set the configuration of the play. If the play is already configured, and the configuration hasn’t changed, this function will return
True
. If the play is not in theGstPlay.PlayState.STOPPED
, this method will returnFalse
and active configuration will remain.config is a
Gst.Structure
that contains the configuration parameters for the play.This function takes ownership of config.
New in version 1.20.
- 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.20.
- 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.20.
- set_mute(val)¶
- Parameters:
val (
bool
) – Mute state the should be set
True
if the currently-playing stream should be muted.New in version 1.20.
- set_rate(rate)¶
- Parameters:
rate (
float
) – playback rate
Playback at specified rate
New in version 1.20.
- set_subtitle_track(stream_index)¶
- Parameters:
stream_index (
int
) – stream index- Returns:
-
Sets the subtitle stack stream_index.
- Return type:
New in version 1.20.
Deprecated since version 1.26: Use
GstPlay.Play.set_subtitle_track_id
() instead.
- set_subtitle_track_enabled(enabled)¶
-
Enable or disable the current subtitle track.
New in version 1.20.
- set_subtitle_track_id(stream_id)¶
- Parameters:
- Returns:
-
Sets the subtitle track stream_id.
- Return type:
New in version 1.26.
- set_subtitle_uri(uri)¶
-
Sets the external subtitle URI. This should be combined with a call to
GstPlay.Play.set_subtitle_track_enabled
(self,True
) so the subtitles are actually rendered.New in version 1.20.
- set_subtitle_video_offset(offset)¶
- Parameters:
offset (
int
) – #gint64 in nanoseconds
Sets subtitle-video-offset property by value of offset
New in version 1.20.
- set_track_ids(audio_stream_id, video_stream_id, subtitle_stream_id)¶
- Parameters:
- Returns:
-
Sets the selected track stream ids. Setting
None
as stream id disables the corresponding track. - Return type:
New in version 1.26.
- set_uri(uri)¶
-
Sets the next URI to play.
New in version 1.20.
- set_video_track(stream_index)¶
- Parameters:
stream_index (
int
) – stream index- Returns:
-
Sets the video track stream_index.
- Return type:
New in version 1.20.
Deprecated since version 1.26: Use
GstPlay.Play.set_video_track_id
() instead.
- set_video_track_enabled(enabled)¶
-
Enable or disable the current video track.
New in version 1.20.
- set_video_track_id(stream_id)¶
- Parameters:
- Returns:
-
Sets the video track stream_id.
- Return type:
New in version 1.26.
- set_visualization(name)¶
- Parameters:
name (
str
orNone
) – visualization element obtained fromGstPlay.Play.visualizations_get
()- Returns:
True
if the visualization was set correctly. Otherwise,False
.- Return type:
New in version 1.20.
- set_visualization_enabled(enabled)¶
-
Enable or disable the visualization.
New in version 1.20.
- 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.
New in version 1.20.
- stop()¶
Stops playing the current stream and resets to the first position in the stream.
New in version 1.20.
Property Details¶
- GstPlay.Play.props.audio_video_offset¶
-
The synchronisation offset between audio and video in nanoseconds
- GstPlay.Play.props.current_audio_track¶
- Name:
current-audio-track
- Type:
- Default Value:
- Flags:
Current audio track information
- GstPlay.Play.props.current_subtitle_track¶
- Name:
current-subtitle-track
- Type:
- Default Value:
- Flags:
Current audio subtitle information
- GstPlay.Play.props.current_video_track¶
- Name:
current-video-track
- Type:
- Default Value:
- Flags:
Current video track information
- GstPlay.Play.props.duration¶
-
Duration
- GstPlay.Play.props.media_info¶
- Name:
media-info
- Type:
- Default Value:
- Flags:
Current media information
- GstPlay.Play.props.pipeline¶
- Name:
pipeline
- Type:
- Default Value:
- Flags:
GStreamer pipeline that is used
- GstPlay.Play.props.position¶
-
Current Position
- GstPlay.Play.props.rate¶
-
Playback rate
- GstPlay.Play.props.subtitle_video_offset¶
-
The synchronisation offset between text and video in nanoseconds
- GstPlay.Play.props.suburi¶
-
Current Subtitle URI
- GstPlay.Play.props.uri¶
-
Current URI
- GstPlay.Play.props.video_multiview_flags¶
- Name:
video-multiview-flags
- Type:
- Default Value:
- Flags:
Override details of the multiview frame layout
- GstPlay.Play.props.video_multiview_mode¶
- Name:
video-multiview-mode
- Type:
- Default Value:
- Flags:
Re-interpret a video stream as one of several frame-packed stereoscopic modes.
- GstPlay.Play.props.video_renderer¶
- Name:
video-renderer
- Type:
- Default Value:
- Flags:
Video renderer to use for rendering videos