Video
Superclasses: Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
GtkVideo
is a widget to show a GtkMediaStream
with media controls.
The controls are available separately as 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 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 Paintable
API and a media framework
such as Gstreamer directly.
Constructors
- class Video
-
- classmethod new_for_file(file: File | None = None) Widget
Creates a
GtkVideo
to play back the givenfile
.- Parameters:
file – a
GFile
- classmethod new_for_filename(filename: str | None = None) Widget
Creates a
GtkVideo
to play back the givenfilename
.This is a utility function that calls
new_for_file
, See that function for details.- Parameters:
filename – filename to play back
- classmethod new_for_media_stream(stream: MediaStream | None = None) Widget
Creates a
GtkVideo
to play back the givenstream
.- Parameters:
stream – a
GtkMediaStream
- classmethod new_for_resource(resource_path: str | None = None) Widget
Creates a
GtkVideo
to play back the resource at the givenresource_path
.This is a utility function that calls
new_for_file
.- Parameters:
resource_path – resource path to play back
Methods
- class Video
-
- get_graphics_offload() GraphicsOffloadEnabled
Returns whether graphics offload is enabled.
See
GraphicsOffload
for more information on graphics offload.Added in version 4.14.
- get_media_stream() MediaStream | None
Gets the media stream managed by
self
orNone
if none.
- set_autoplay(autoplay: bool) None
Sets whether
self
automatically starts playback when it becomes visible or when a new file gets loaded.- Parameters:
autoplay – whether media streams should autoplay
- set_file(file: File | None = None) None
Makes
self
play the givenfile
.- Parameters:
file – the file to play
- set_filename(filename: str | None = None) None
Makes
self
play the givenfilename
.This is a utility function that calls
set_file()
,- Parameters:
filename – the filename to play
- set_graphics_offload(enabled: GraphicsOffloadEnabled) None
Sets whether to enable graphics offload.
See
GraphicsOffload
for more information on graphics offload.Added in version 4.14.
- Parameters:
enabled – the new graphics offload status
- set_loop(loop: bool) None
Sets whether new files loaded by
self
should be set to loop.- Parameters:
loop – whether media streams should loop
- set_media_stream(stream: MediaStream | None = None) None
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 aPicture
for display.If you want to display a file, consider using
set_file
instead.- Parameters:
stream – The media stream to play or
None
to unset
Properties
- class Video
-
- props.graphics_offload: GraphicsOffloadEnabled
Whether to enable graphics offload.
Added in version 4.14.
- props.media_stream: MediaStream
The media-stream played