MediaFile

class MediaFile(**properties: Any)

Superclasses: MediaStream, Object

Implemented Interfaces: Paintable

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 an implementation using GStreamer.

Constructors

class MediaFile
classmethod new() MediaFile

Creates a new empty media file.

classmethod new_for_file(file: File) MediaFile

Creates a new media file to play file.

Parameters:

file – The file to play

classmethod new_for_filename(filename: str) 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 new_for_file.

Parameters:

filename – filename to open

classmethod new_for_input_stream(stream: InputStream) 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.

Parameters:

stream – The stream to play

classmethod new_for_resource(resource_path: str) 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 new_for_file.

Parameters:

resource_path – resource path to open

Methods

class MediaFile
clear() None

Resets the media file to be empty.

get_file() File | 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() InputStream | 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: File | None = None) None

Sets the GtkMediaFile to play the given file.

If any file is still playing, stop playing it.

Parameters:

file – the file to play

set_filename(filename: str | None = None) None

Sets the `GtkMediaFile to play the given file.

This is a utility function that converts the given filename to a GFile and calls set_file.

Parameters:

filename – name of file to play

set_input_stream(stream: InputStream | None = None) None

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.

Parameters:

stream – the stream to play from

set_resource(resource_path: str | None = None) None

Sets the `GtkMediaFile to play the given resource.

This is a utility function that converts the given resource_path to a GFile and calls set_file.

Parameters:

resource_path – path to resource to play

Properties

class MediaFile
props.file: File

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

props.input_stream: InputStream

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

This is None when playing a file.

Virtual Methods

class MediaFile
do_close() None
do_open() None

Fields

class MediaFile
parent_instance