Gtk.MediaFile¶
class — extends MediaStream, Gdk.Paintable
Implements the GtkMediaStream interface 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¶
new¶
Creates a new empty media file.
new_for_file¶
Creates a new media file to play file.
Parameters:
file— The file to play
new_for_filename¶
@classmethod
def new_for_filename(cls, filename: str | bytes | os.PathLike[str] | os.PathLike[bytes]) -> 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 MediaFile.new_for_file.
Parameters:
filename— filename to open
new_for_input_stream¶
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
new_for_resource¶
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 MediaFile.new_for_file.
Parameters:
resource_path— resource path to open
Methods¶
clear¶
Resets the media file to be empty.
get_file¶
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¶
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¶
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¶
def set_filename(self, filename: str | bytes | os.PathLike[str] | os.PathLike[bytes] | 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 MediaFile.set_file.
Parameters:
filename— name of file to play
set_input_stream¶
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¶
Sets the GtkMediaFile to play the given resource.
This is a utility function that converts the given resource_path
to a GFile and calls MediaFile.set_file.
Parameters:
resource_path— path to resource to play
Virtual methods¶
do_close¶
do_open¶
Properties¶
file¶
The file being played back or None if not playing a file.
input_stream¶
The stream being played back or None if not playing a stream.
This is None when playing a file.