:right-sidebar: True MediaFile =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: MediaFile(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.MediaStream`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gdk.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 ------------ .. rst-class:: interim-class .. class:: MediaFile :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.MediaFile Creates a new empty media file. .. classmethod:: new_for_file(file: ~gi.repository.Gio.File) -> ~gi.repository.Gtk.MediaFile Creates a new media file to play ``file``. :param file: The file to play .. classmethod:: new_for_filename(filename: str) -> ~gi.repository.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 :obj:`~gi.repository.Gtk.MediaFile.new_for_file`. :param filename: filename to open .. classmethod:: new_for_input_stream(stream: ~gi.repository.Gio.InputStream) -> ~gi.repository.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. :param stream: The stream to play .. classmethod:: new_for_resource(resource_path: str) -> ~gi.repository.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 :obj:`~gi.repository.Gtk.MediaFile.new_for_file`. :param resource_path: resource path to open Methods ------- .. rst-class:: interim-class .. class:: MediaFile :no-index: .. method:: clear() -> None Resets the media file to be empty. .. method:: get_file() -> ~gi.repository.Gio.File | None Returns the file that ``self`` is currently playing from. When ``self`` is not playing or not playing from a file, :const:`None` is returned. .. method:: get_input_stream() -> ~gi.repository.Gio.InputStream | None Returns the stream that ``self`` is currently playing from. When ``self`` is not playing or not playing from a stream, :const:`None` is returned. .. method:: set_file(file: ~gi.repository.Gio.File | None = None) -> None Sets the ``GtkMediaFile`` to play the given file. If any file is still playing, stop playing it. :param file: the file to play .. method:: 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 :obj:`~gi.repository.Gtk.MediaFile.set_file`. :param filename: name of file to play .. method:: set_input_stream(stream: ~gi.repository.Gio.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. :param stream: the stream to play from .. method:: 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 :obj:`~gi.repository.Gtk.MediaFile.set_file`. :param resource_path: path to resource to play Properties ---------- .. rst-class:: interim-class .. class:: MediaFile :no-index: .. attribute:: props.file :type: ~gi.repository.Gio.File The file being played back or :const:`None` if not playing a file. .. attribute:: props.input_stream :type: ~gi.repository.Gio.InputStream The stream being played back or :const:`None` if not playing a stream. This is :const:`None` when playing a file. Virtual Methods --------------- .. rst-class:: interim-class .. class:: MediaFile :no-index: .. method:: do_close() -> None .. method:: do_open() -> None Fields ------ .. rst-class:: interim-class .. class:: MediaFile :no-index: .. attribute:: parent_instance