Clapper.Player¶
- Subclasses:
None
Methods¶
- Inherited:
Clapper.ThreadedObject (1), Gst.Object (27), GObject.Object (37)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Clapper.ThreadedObject (2), Gst.Object (1), GObject.Object (7)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/en |
|||
r/w/en |
|||
r/en |
|||
r/en |
|||
r/w/en |
|||
r/en |
|||
r/en |
|||
r/w/en |
|||
r/en |
|||
r/w/en |
|||
r/w/en |
|||
r/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
These are normal error messages. |
|
A #GStreamer plugin or one of its features needed for playback is missing. |
|
A seeking operation has finished. |
|
These are some usually more minor error messages that should be treated like warnings. |
Fields¶
- Inherited:
Class Details¶
- class Clapper.Player(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The media player object used for playback.
Clapper.Player
was written in an easy to use way, so no special GStreamer experience is needed to get started with making various playback applications.Scheduling media for playback is done using a [class`Clapper`.Queue] upon which player operates.
Player uses
GStreamer
internally and handles playback on a separate thread, while serializing all events/commands between player and the thread it was created upon (usually main app thread). This makes it very easy to integrate with UI toolkits that operate on a single thread like (but not limited to) GTK.To listen for property changes, you can connect to property “notify” signal.
- classmethod new()¶
- Returns:
a new
Clapper.Player
instance.- Return type:
Creates a new
Clapper.Player
instance.
- add_feature(feature)¶
- Parameters:
feature (
Clapper.Feature
) – aClapper.Feature
Add another
Clapper.Feature
to the player.
- get_audio_enabled()¶
-
Get whether audio stream is enabled.
- get_audio_filter()¶
- Returns:
Gst.Element
set as audio filter.- Return type:
Get
Gst.Element
used as audio filter.
- get_audio_offset()¶
- Returns:
the audio stream offset.
- Return type:
Get the currently set audio stream offset.
The returned value is in seconds as a decimal number.
- get_audio_sink()¶
- Returns:
Gst.Element
set as audio sink.- Return type:
Get
Gst.Element
used as audio sink.
- get_audio_streams()¶
- Returns:
a
Clapper.StreamList
of audioClapper.Stream
.- Return type:
Get a list of audio streams within media item.
- get_autoplay()¶
-
Get the autoplay value.
- get_current_audio_decoder()¶
- Returns:
Gst.Element
currently used as audio decoder.- Return type:
Get
Gst.Element
currently used as audio decoder.
- get_current_video_decoder()¶
- Returns:
Gst.Element
currently used as video decoder.- Return type:
Get
Gst.Element
currently used as video decoder.
- get_mute()¶
-
Get the mute state of the player.
- get_position()¶
- Returns:
the position of the player.
- Return type:
Get the current player playback position.
The returned value is in seconds as a decimal number.
- get_queue()¶
- Returns:
the
Clapper.Queue
of the player.- Return type:
Get the
Clapper.Queue
of the player.The queue belongs to the player and can be accessed for as long as
Clapper.Player
object instance it belongs to is alive.
- get_speed()¶
- Returns:
the playback speed multiplier.
- Return type:
Get the speed of the player used for playback.
- get_state()¶
- Returns:
the
Clapper.PlayerState
of the player.- Return type:
Get the current
Clapper.PlayerState
.
- get_subtitle_font_desc()¶
- Returns:
the subtitle font description.
- Return type:
Get the currently set font description used for subtitle stream rendering.
- get_subtitle_offset()¶
- Returns:
the subtitle stream offset.
- Return type:
Get the currently set subtitle stream offset.
The returned value is in seconds as a decimal number.
- get_subtitle_streams()¶
- Returns:
a
Clapper.StreamList
of subtitleClapper.Stream
.- Return type:
Get a list of subtitle streams within media item.
- get_subtitles_enabled()¶
-
Get whether subtitles are to be shown when available.
- get_video_enabled()¶
-
Get whether video stream is enabled.
- get_video_filter()¶
- Returns:
Gst.Element
set as video filter.- Return type:
Get
Gst.Element
used as video filter.
- get_video_sink()¶
- Returns:
Gst.Element
set as video sink.- Return type:
Get
Gst.Element
used as video sink.
- get_video_streams()¶
- Returns:
a
Clapper.StreamList
of videoClapper.Stream
.- Return type:
Get a list of video streams within media item.
- pause()¶
Pause the playback of current media item.
This function will queue a request for the underlaying #GStreamer pipeline to go into
PAUSED
state, thus can also be used on a not yet started video to go intoPAUSED
state first.
- play()¶
Either start or resume the playback of current media item.
This function will queue a request for the underlaying #GStreamer pipeline to go into
PLAYING
state.
- seek(position)¶
- Parameters:
position (
float
) – a decimal number with position to seek to (in seconds)
Request the player to perform a seek operation.
This function will use [enum`Clapper`.PlayerSeekMethod.NORMAL] as a seeking method. If you wish to specify what method to use per seeking request, use [method`Clapper`.Player.seek_custom] instead.
Note that seeking requests are per selected media item. Seeking requests will be ignored if player is stopped. You need to at least call [method`Clapper`.Player.pause] before seeking and then your requested seek will be handled if item could be played.
- seek_custom(position, method)¶
- Parameters:
position (
float
) – a decimal number with position to seek to (in seconds)method (
Clapper.PlayerSeekMethod
) – aClapper.PlayerSeekMethod
Request the player to perform a seek operation.
Same as [method`Clapper`.Player.seek], but also allows to specify [enum`Clapper`.PlayerSeekMethod] to use for seek.
- set_audio_enabled(enabled)¶
- Parameters:
enabled (
bool
) – whether enabled
Set whether enable audio stream.
- set_audio_filter(element)¶
- Parameters:
element (
Gst.Element
orNone
) – aGst.Element
orNone
for none.
Set
Gst.Element
to be used as audio filter.
- set_audio_offset(offset)¶
- Parameters:
offset (
float
) – a decimal audio offset (in seconds)
Set synchronisation offset between the audio stream and video.
Positive values make the audio ahead of the video and negative values make the audio go behind the video.
- set_audio_sink(element)¶
- Parameters:
element (
Gst.Element
orNone
) – aGst.Element
orNone
to use default.
Set
Gst.Element
to be used as audio sink.
- set_autoplay(enabled)¶
-
Set the autoplay state of the player.
When autoplay is enabled, player will always try to start playback after current media item changes. When disabled current playback state is preserved when changing items.
- set_mute(mute)¶
-
Set the mute state of the player.
- set_speed(speed)¶
- Parameters:
speed (
float
) – the playback speed multiplier.
Set the speed multiplier of the player.
- set_subtitle_font_desc(font_desc)¶
- Parameters:
font_desc (
str
) – Font description
Set Pango font description to be used for subtitle stream rendering.
- set_subtitle_offset(offset)¶
- Parameters:
offset (
float
) – a decimal subtitle stream offset (in seconds)
Set synchronisation offset between the subtitle stream and video.
Positive values make the subtitles ahead of the video and negative values make the subtitles go behind the video.
- set_subtitles_enabled(enabled)¶
- Parameters:
enabled (
bool
) – whether enabled
Set whether subtitles should be shown if any.
- set_video_enabled(enabled)¶
- Parameters:
enabled (
bool
) – whether enabled
Set whether enable video stream.
- set_video_filter(element)¶
- Parameters:
element (
Gst.Element
orNone
) – aGst.Element
orNone
for none.
Set
Gst.Element
to be used as video filter.
- set_video_sink(element)¶
- Parameters:
element (
Gst.Element
orNone
) – aGst.Element
orNone
to use default.
Set
Gst.Element
to be used as video sink.
- set_volume(volume)¶
- Parameters:
volume (
float
) – the volume level.
Set the volume of the player.
The value should be within 0 - 2.0 range, where 1.0 is 100% volume and anything above results with an overamplification.
- stop()¶
Stop the playback of current media item.
This function will queue a request for the underlaying #GStreamer pipeline to go into
READY
state.
Signal Details¶
- Clapper.Player.signals.error(player, error, debug_info)¶
- Signal Name:
error
- Flags:
- Parameters:
player (
Clapper.Player
) – The object which received the signalerror (
GLib.Error
) – aGLib.Error
These are normal error messages. Upon emitting this signal, playback will stop due to the error.
- Clapper.Player.signals.missing_plugin(player, name, installer_detail)¶
- Signal Name:
missing-plugin
- Flags:
- Parameters:
player (
Clapper.Player
) – The object which received the signalname (
str
) – a localised string describing the missing feature, for use in error dialogs and the like.installer_detail (
str
orNone
) – a string containing all the details about the missing element to be passed to an external installer called via eitherGstPbutils.install_plugins_async
() orGstPbutils.install_plugins_sync
() function.
A #GStreamer plugin or one of its features needed for playback is missing.
The description and installer_detail can be used to present the user more info about what is missing and prompt him to install it with an external installer.
- Clapper.Player.signals.seek_done(player)¶
- Signal Name:
seek-done
- Flags:
- Parameters:
player (
Clapper.Player
) – The object which received the signal
A seeking operation has finished. Player is now at playback position after seek.
- Clapper.Player.signals.warning(player, error, debug_info)¶
- Signal Name:
warning
- Flags:
- Parameters:
player (
Clapper.Player
) – The object which received the signalerror (
GLib.Error
) – aGLib.Error
These are some usually more minor error messages that should be treated like warnings. Should not generally prevent/stop playback.
Property Details¶
- Clapper.Player.props.audio_enabled¶
- Name:
audio-enabled
- Type:
- Default Value:
- Flags:
Whether audio stream is enabled.
- Clapper.Player.props.audio_filter¶
- Name:
audio-filter
- Type:
- Default Value:
- Flags:
Optional audio filter to use (none by default).
- Clapper.Player.props.audio_offset¶
- Name:
audio-offset
- Type:
- Default Value:
0.0
- Flags:
Audio stream offset relative to video.
- Clapper.Player.props.audio_sink¶
- Name:
audio-sink
- Type:
- Default Value:
- Flags:
Audio sink to use (autoaudiosink by default).
- Clapper.Player.props.audio_streams¶
- Name:
audio-streams
- Type:
- Default Value:
- Flags:
List of currently available audio streams.
- Clapper.Player.props.autoplay¶
- Name:
autoplay
- Type:
- Default Value:
- Flags:
Always try to start playback after media item changes.
- Clapper.Player.props.current_audio_decoder¶
- Name:
current-audio-decoder
- Type:
- Default Value:
- Flags:
Currently used audio decoder.
- Clapper.Player.props.current_video_decoder¶
- Name:
current-video-decoder
- Type:
- Default Value:
- Flags:
Currently used video decoder.
- Clapper.Player.props.mute¶
- Name:
mute
- Type:
- Default Value:
- Flags:
Mute audio without changing volume.
- Clapper.Player.props.position¶
- Name:
position
- Type:
- Default Value:
0.0
- Flags:
Current playback position as a decimal number in seconds.
- Clapper.Player.props.queue¶
- Name:
queue
- Type:
- Default Value:
- Flags:
Clapper playback queue.
- Clapper.Player.props.speed¶
- Name:
speed
- Type:
- Default Value:
1.0
- Flags:
Current playback speed.
- Clapper.Player.props.state¶
- Name:
state
- Type:
- Default Value:
- Flags:
Current playback state.
- Clapper.Player.props.subtitle_font_desc¶
- Name:
subtitle-font-desc
- Type:
- Default Value:
- Flags:
Subtitle stream font description.
- Clapper.Player.props.subtitle_offset¶
- Name:
subtitle-offset
- Type:
- Default Value:
0.0
- Flags:
Subtitle stream offset relative to video.
- Clapper.Player.props.subtitle_streams¶
- Name:
subtitle-streams
- Type:
- Default Value:
- Flags:
List of currently available subtitle streams.
- Clapper.Player.props.subtitles_enabled¶
- Name:
subtitles-enabled
- Type:
- Default Value:
- Flags:
Whether subtitles stream is enabled.
- Clapper.Player.props.video_enabled¶
- Name:
video-enabled
- Type:
- Default Value:
- Flags:
Whether video stream is enabled.
- Clapper.Player.props.video_filter¶
- Name:
video-filter
- Type:
- Default Value:
- Flags:
Optional video filter to use (none by default).
- Clapper.Player.props.video_sink¶
- Name:
video-sink
- Type:
- Default Value:
- Flags:
Video sink to use (autovideosink by default).
- Clapper.Player.props.video_streams¶
- Name:
video-streams
- Type:
- Default Value:
- Flags:
List of currently available video streams.
- Clapper.Player.props.volume¶
- Name:
volume
- Type:
- Default Value:
1.0
- Flags:
Current volume as a decimal number (1.0 = 100%).
Note that
Clapper.Player
uses a CUBIC volume scale, meaning that this property value reflects human hearing level and can be easily bound to volume sliders as-is.