Gtk.MediaFile

g GObject.GInterface GObject.GInterface Gdk.Paintable Gdk.Paintable GObject.GInterface->Gdk.Paintable GObject.Object GObject.Object Gtk.MediaStream Gtk.MediaStream GObject.Object->Gtk.MediaStream Gdk.Paintable->Gtk.MediaStream Gtk.MediaFile Gtk.MediaFile Gtk.MediaStream->Gtk.MediaFile

Subclasses:

None

Methods

Inherited:

Gtk.MediaStream (29), GObject.Object (37), Gdk.Paintable (10)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_for_file (file)

class

new_for_filename (filename)

class

new_for_input_stream (stream)

class

new_for_resource (resource_path)

clear ()

get_file ()

get_input_stream ()

set_file (file)

set_filename (filename)

set_input_stream (stream)

set_resource (resource_path)

Virtual Methods

Inherited:

Gtk.MediaStream (6), GObject.Object (7), Gdk.Paintable (6)

do_close ()

do_open ()

Properties

Inherited:

Gtk.MediaStream (13)

Name

Type

Flags

Short Description

file

Gio.File

r/w/en

input-stream

Gio.InputStream

r/w/en

Signals

Inherited:

GObject.Object (1), Gdk.Paintable (2)

Fields

Inherited:

GObject.Object (1), Gdk.Paintable (2)

Name

Type

Access

Description

parent_instance

Gtk.MediaStream

r

Class Details

class Gtk.MediaFile(**kwargs)
Bases:

Gtk.MediaStream

Abstract:

Yes

Structure:

Gtk.MediaFileClass

GtkMediaFile implements GtkMediaStream for files.

This provides a simple way to play back video files with GTK.

GTK provides a GIO extension point for GtkMediaFile implementations to allow for external implementations using various media frameworks.

GTK itself includes implementations using GStreamer and ffmpeg.

classmethod new()[source]
Returns:

a new GtkMediaFile

Return type:

Gtk.MediaFile

Creates a new empty media file.

classmethod new_for_file(file)[source]
Parameters:

file (Gio.File) – The file to play

Returns:

a new GtkMediaFile playing file

Return type:

Gtk.MediaFile

Creates a new media file to play file.

classmethod new_for_filename(filename)[source]
Parameters:

filename (str) – filename to open

Returns:

a new GtkMediaFile playing filename

Return type:

Gtk.MediaFile

Creates a new media file for the given filename.

This is a utility function that converts the given filename to a GFile and calls [ctor`Gtk`.MediaFile.new_for_file].

classmethod new_for_input_stream(stream)[source]
Parameters:

stream (Gio.InputStream) – The stream to play

Returns:

a new GtkMediaFile

Return type:

Gtk.MediaFile

Creates a new media file to play stream.

If you want the resulting media to be seekable, the stream should implement the GSeekable interface.

classmethod new_for_resource(resource_path)[source]
Parameters:

resource_path (str) – resource path to open

Returns:

a new GtkMediaFile playing resource_path

Return type:

Gtk.MediaFile

Creates a new new media file for the given resource.

This is a utility function that converts the given resource to a GFile and calls [ctor`Gtk`.MediaFile.new_for_file].

clear()[source]

Resets the media file to be empty.

get_file()[source]
Returns:

The currently playing file

Return type:

Gio.File or None

Returns the file that self is currently playing from.

When self is not playing or not playing from a file, None is returned.

get_input_stream()[source]
Returns:

The currently playing stream

Return type:

Gio.InputStream or None

Returns the stream that self is currently playing from.

When self is not playing or not playing from a stream, None is returned.

set_file(file)[source]
Parameters:

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

Sets the GtkMediaFile to play the given file.

If any file is still playing, stop playing it.

set_filename(filename)[source]
Parameters:

filename (str or None) – name of file to play

Sets the `:obj:Gtk.MediaFile to play the given file.

This is a utility function that converts the given filename to a GFile and calls [method`Gtk`.MediaFile.set_file].

set_input_stream(stream)[source]
Parameters:

stream (Gio.InputStream or None) – the stream to play from

Sets the GtkMediaFile to play the given stream.

If anything is still playing, stop playing it.

Full control about the stream is assumed for the duration of playback. The stream will not be closed.

set_resource(resource_path)[source]
Parameters:

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

Sets the `:obj:Gtk.MediaFile to play the given resource.

This is a utility function that converts the given resource_path to a GFile and calls [method`Gtk`.MediaFile.set_file].

do_close() virtual
do_open() virtual

Property Details

Gtk.MediaFile.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The file being played back or None if not playing a file.

Gtk.MediaFile.props.input_stream
Name:

input-stream

Type:

Gio.InputStream

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The stream being played back or None if not playing a stream.

This is None when playing a file.