ClapperGtk.Video

g ClapperGtk.Video ClapperGtk.Video GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->ClapperGtk.Video

Subclasses:

None

Methods

Inherited:

Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

add_fading_overlay (widget)

add_overlay (widget)

get_auto_inhibit ()

get_fade_delay ()

get_inhibited ()

get_player ()

get_touch_fade_delay ()

set_auto_inhibit (inhibit)

set_fade_delay (delay)

set_touch_fade_delay (delay)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (35), Gtk.Accessible (1)

Name

Type

Flags

Short Description

auto-inhibit

bool

r/w/en

fade-delay

int

r/w/en

inhibited

bool

r/en

player

Clapper.Player

r/en

touch-fade-delay

int

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

seek-request

A helper signal for implementing common seeking by double tap on screen side for touchscreen devices.

toggle-fullscreen

A signal that user requested a change in fullscreen state of the video.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class ClapperGtk.Video(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

Structure:

ClapperGtk.VideoClass

A ready to be used GTK video widget implementing Clapper API.

ClapperGtk.Video is the main widget exposed by ClapperGtk API. It both displays videos played by [class`Clapper`.Player] (exposed as its property) and manages revealing and fading of any additional widgets overlaid on top of it.

Other widgets provided by ClapperGtk library, once placed anywhere on video (including nesting within another widget like [class`Gtk`.Box]) will automatically control ClapperGtk.Video they were overlaid on top of. This allows to freely create custom playback control panels best suited for specific application. Additionally, pre-made widgets such as [class`ClapperGtk`.SimpleControls] are also available.

Basic usage

A typical use case is to embed video widget as part of your app where video playback is needed. Get the [class`Clapper`.Player] belonging to the video widget and start adding new [class`Clapper`.MediaItem] items to the [class`Clapper`.Queue] for playback. For more information please refer to the Clapper playback library documentation.

ClapperGtk.Video can automatically take care of revealing and later fading overlaid content when interacting with the video. To do this, simply add your widgets with [method`ClapperGtk`.Video.add_fading_overlay]. If you want to display some static content on top of video (or take care of visibility within overlaid widget itself) you can add it to the video as a normal overlay with [method`ClapperGtk`.Video.add_overlay].

Actions

ClapperGtk.Video defines a set of built-in actions:

```yaml

  • “video.toggle-play”: toggle play/pause

  • “video.play”: start/resume playback

  • “video.pause”: pause playback

  • “video.stop”: stop playback

  • “video.seek”: seek to position (variant “d”)

  • “video.seek-custom”: seek to position using seek method (variant “(di)”)

  • “video.toggle-mute”: toggle mute state

  • “video.set-mute”: set mute state (variant “b”)

  • “video.volume-up”: increase volume by 2%

  • “video.volume-down”: decrease volume by 2%

  • “video.set-volume”: set volume to specified value (variant “d”)

  • “video.speed-up”: increase speed (from 0.05x - 2x range to nearest quarter)

  • “video.speed-down”: decrease speed (from 0.05x - 2x range to nearest quarter)

  • “video.set-speed”: set speed to specified value (variant “d”)

  • “video.previous-item”: select previous item in queue

  • “video.next-item”: select next item in queue

  • “video.select-item”: select item at specified index in queue (variant “u”) ```

ClapperGtk.Video as Gtk.Buildable

ClapperGtk.Video implementation of the [iface`Gtk`.Buildable] interface supports placing children as either normal overlay by specifying overlay or a fading one by specifying fading-overlay as the type attribute of a <child> element. Position of overlaid content is determined by valign/halign properties.

``xml <object class=”ClapperGtkVideo” id=”video”>

<child type=”fading-overlay”>
<object class=”ClapperGtkTitleHeader”>

<property name=”valign”>start</property>

</object>

</child> <child type=”fading-overlay”>

<object class=”ClapperGtkSimpleControls”>

<property name=”valign”>end</property>

</object>

</child>

</object> ``

classmethod new()
Returns:

a new video Gtk.Widget.

Return type:

Gtk.Widget

Creates a new ClapperGtk.Video instance.

Newly created video widget will also set some default GStreamer elements on its [class`Clapper`.Player]. This includes Clapper own video sink and a “scaletempo” element as audio filter. Both can still be changed after construction by setting corresponding player properties.

add_fading_overlay(widget)
Parameters:

widget (Gtk.Widget) – a Gtk.Widget

Similiar as ClapperGtk.Video.add_overlay() but will also automatically add fading functionality to overlaid Gtk.Widget for convenience. This will make widget reveal itself when interacting with self and fade otherwise. Useful when placing widgets such as playback controls panels.

add_overlay(widget)
Parameters:

widget (Gtk.Widget) – a Gtk.Widget

Add another Gtk.Widget to be overlaid on top of video.

The position at which widget is placed is determined from [property`Gtk`.Widget:halign] and [property`Gtk`.Widget:valign] properties.

This function will overlay widget as-is meaning that widget is responsible for managing its own visablity if needed. If you want to add a Gtk.Widget that will reveal and fade itself automatically when interacting with self (e.g. controls panel) you can use ClapperGtk.Video.add_fading_overlay() function for convenience.

get_auto_inhibit()
Returns:

True if enabled, False otherwise.

Return type:

bool

Get whether automatic session inhibit is enabled.

get_fade_delay()
Returns:

currently set fade delay.

Return type:

int

Get time in milliseconds after which fading overlays should fade.

get_inhibited()
Returns:

True if inhibited, False otherwise.

Return type:

bool

Get whether session is currently inhibited by [property`ClapperGtk`.Video:auto-inhibit].

get_player()
Returns:

a Clapper.Player used by video.

Return type:

Clapper.Player

Get Clapper.Player used by this ClapperGtk.Video instance.

get_touch_fade_delay()
Returns:

currently set touch fade delay.

Return type:

int

Get time in milliseconds after which fading overlays should fade when revealed using touch device.

set_auto_inhibit(inhibit)
Parameters:

inhibit (bool) – whether to enable automatic session inhibit

Set whether video should try to automatically inhibit session from idling (and possibly screen going black) when video is playing.

set_fade_delay(delay)
Parameters:

delay (int) – a fade delay

Set time in milliseconds after which fading overlays should fade.

set_touch_fade_delay(delay)
Parameters:

delay (int) – a touch fade delay

Set time in milliseconds after which fading overlays should fade when using touchscreen.

It is often useful to set this higher then normal fade delay property, as in case of touch events user do not have a moving pointer that would extend fade timeout, so he can have more time to decide what to press next.

Signal Details

ClapperGtk.Video.signals.seek_request(video, forward)
Signal Name:

seek-request

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

A helper signal for implementing common seeking by double tap on screen side for touchscreen devices.

Note that forward already takes into account RTL direction, so implementation does not have to check.

ClapperGtk.Video.signals.toggle_fullscreen(video)
Signal Name:

toggle-fullscreen

Flags:

RUN_LAST, NO_RECURSE, NO_HOOKS

Parameters:

video (ClapperGtk.Video) – The object which received the signal

A signal that user requested a change in fullscreen state of the video.

Note that when going fullscreen from this signal, user will expect for only video to be fullscreened and not the whole app window. It is up to implementation to decide how to handle that.

Property Details

ClapperGtk.Video.props.auto_inhibit
Name:

auto-inhibit

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Try to automatically inhibit session when video is playing.

ClapperGtk.Video.props.fade_delay
Name:

fade-delay

Type:

int

Default Value:

3000

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A delay in milliseconds before trying to fade all fading overlays.

ClapperGtk.Video.props.inhibited
Name:

inhibited

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

Get whether session is currently inhibited by the video.

ClapperGtk.Video.props.player
Name:

player

Type:

Clapper.Player

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

A Clapper.Player used by video.

ClapperGtk.Video.props.touch_fade_delay
Name:

touch-fade-delay

Type:

int

Default Value:

5000

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A delay in milliseconds before trying to fade all fading overlays after revealed using touchscreen.