Gtk.Video

g 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.Video Gtk.Video Gtk.Widget->Gtk.Video

Example

../_images/Video.png
Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

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

class

new ()

class

new_for_file (file)

class

new_for_filename (filename)

class

new_for_media_stream (stream)

class

new_for_resource (resource_path)

get_autoplay ()

get_file ()

get_loop ()

get_media_stream ()

set_autoplay (autoplay)

set_file (file)

set_filename (filename)

set_loop (loop)

set_media_stream (stream)

set_resource (resource_path)

Virtual Methods

Inherited:

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

Properties

Inherited:

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

Name

Type

Flags

Short Description

autoplay

bool

r/w/en

file

Gio.File

r/w/en

loop

bool

r/w/en

media-stream

Gtk.MediaStream

r/w/en

Signals

Inherited:

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

Fields

Inherited:

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

Class Details

class Gtk.Video(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

Structure:

Gtk.VideoClass

GtkVideo is a widget to show a GtkMediaStream with media controls.

An example Gtk.Video

The controls are available separately as [class`Gtk`.MediaControls]. If you just want to display a video without controls, you can treat it like any other paintable and for example put it into a [class`Gtk`.Picture].

GtkVideo aims to cover use cases such as previews, embedded animations, etc. It supports autoplay, looping, and simple media controls. It does not have support for video overlays, multichannel audio, device selection, or input. If you are writing a full-fledged video player, you may want to use the [iface`Gdk`.Paintable] API and a media framework such as Gstreamer directly.

classmethod new()[source]
Returns:

a new GtkVideo

Return type:

Gtk.Widget

Creates a new empty GtkVideo.

classmethod new_for_file(file)[source]
Parameters:

file (Gio.File or None) – a GFile

Returns:

a new GtkVideo

Return type:

Gtk.Widget

Creates a GtkVideo to play back the given file.

classmethod new_for_filename(filename)[source]
Parameters:

filename (str or None) – filename to play back

Returns:

a new GtkVideo

Return type:

Gtk.Widget

Creates a GtkVideo to play back the given filename.

This is a utility function that calls [ctor`Gtk`.Video.new_for_file], See that function for details.

classmethod new_for_media_stream(stream)[source]
Parameters:

stream (Gtk.MediaStream or None) – a GtkMediaStream

Returns:

a new GtkVideo

Return type:

Gtk.Widget

Creates a GtkVideo to play back the given stream.

classmethod new_for_resource(resource_path)[source]
Parameters:

resource_path (str or None) – resource path to play back

Returns:

a new GtkVideo

Return type:

Gtk.Widget

Creates a GtkVideo to play back the resource at the given resource_path.

This is a utility function that calls [ctor`Gtk`.Video.new_for_file].

get_autoplay()[source]
Returns:

True if streams should autoplay

Return type:

bool

Returns True if videos have been set to loop.

get_file()[source]
Returns:

The file played by self

Return type:

Gio.File or None

Gets the file played by self or None if not playing back a file.

get_loop()[source]
Returns:

True if streams should loop

Return type:

bool

Returns True if videos have been set to loop.

get_media_stream()[source]
Returns:

The media stream managed by self

Return type:

Gtk.MediaStream or None

Gets the media stream managed by self or None if none.

set_autoplay(autoplay)[source]
Parameters:

autoplay (bool) – whether media streams should autoplay

Sets whether self automatically starts playback when it becomes visible or when a new file gets loaded.

set_file(file)[source]
Parameters:

file (Gio.File or None) – the file to play

Makes self play the given file.

set_filename(filename)[source]
Parameters:

filename (str or None) – the filename to play

Makes self play the given filename.

This is a utility function that calls Gtk.Video.set_file(),

set_loop(loop)[source]
Parameters:

loop (bool) – whether media streams should loop

Sets whether new files loaded by self should be set to loop.

set_media_stream(stream)[source]
Parameters:

stream (Gtk.MediaStream or None) – The media stream to play or None to unset

Sets the media stream to be played back.

self will take full control of managing the media stream. If you want to manage a media stream yourself, consider using a [class`Gtk`.Picture] for display.

If you want to display a file, consider using [method`Gtk`.Video.set_file] instead.

set_resource(resource_path)[source]
Parameters:

resource_path (str or None) – the resource to set

Makes self play the resource at the given resource_path.

This is a utility function that calls [method`Gtk`.Video.set_file].

Property Details

Gtk.Video.props.autoplay
Name:

autoplay

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the video should automatically begin playing.

Gtk.Video.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The file played by this video if the video is playing a file.

Gtk.Video.props.loop
Name:

loop

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If new media files should be set to loop.

Gtk.Video.props.media_stream
Name:

media-stream

Type:

Gtk.MediaStream

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The media-stream played