Class MediaFile

All Implemented Interfaces:
PointerInterface

public class MediaFile extends MediaStream
`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.

https://docs.gtk.org/gtk4/class.MediaFile.html

  • Constructor Details

    • MediaFile

      public MediaFile(PointerContainer pointer)
    • MediaFile

      public MediaFile()
      Creates a new empty media file.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newForFileMediaFile

      public static MediaFile newForFileMediaFile(@Nonnull File file)
      Creates a new media file to play @file.
      Parameters:
      file - The file to play
      Returns:
      a new `GtkMediaFile` playing @file
    • newForFilenameMediaFile

      public static MediaFile newForFilenameMediaFile(@Nonnull Str filename)
      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].
      Parameters:
      filename - filename to open
      Returns:
      a new `GtkMediaFile` playing @filename
    • newForFilenameMediaFile

      public static MediaFile newForFilenameMediaFile(String filename)
      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].
      Parameters:
      filename - filename to open
      Returns:
      a new `GtkMediaFile` playing @filename
    • newForInputStreamMediaFile

      public static MediaFile newForInputStreamMediaFile(@Nonnull InputStream 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
      Returns:
      a new `GtkMediaFile`
    • newForResourceMediaFile

      public static MediaFile newForResourceMediaFile(@Nonnull Str resource_path)
      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].
      Parameters:
      resource_path - resource path to open
      Returns:
      a new `GtkMediaFile` playing @resource_path
    • newForResourceMediaFile

      public static MediaFile newForResourceMediaFile(String resource_path)
      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].
      Parameters:
      resource_path - resource path to open
      Returns:
      a new `GtkMediaFile` playing @resource_path
    • clear

      public void clear()
      Resets the media file to be empty.
    • getFile

      public File getFile()
      Returns the file that @self is currently playing from.

      When @self is not playing or not playing from a file,
      %NULL is returned.
      Returns:
      The currently playing file
    • getInputStream

      public InputStream getInputStream()
      Returns the stream that @self is currently playing from.

      When @self is not playing or not playing from a stream,
      %NULL is returned.
      Returns:
      The currently playing stream
    • setFile

      public void setFile(@Nullable File file)
      Sets the `GtkMediaFile` to play the given file.

      If any file is still playing, stop playing it.
      Parameters:
      file - the file to play
    • setFilename

      public void setFilename(@Nullable Str filename)
      Sets the `GtkMediaFile 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].
      Parameters:
      filename - name of file to play
    • setFilename

      public void setFilename(String filename)
      Sets the `GtkMediaFile 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].
      Parameters:
      filename - name of file to play
    • setInputStream

      public void setInputStream(@Nullable InputStream 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
    • setResource

      public void setResource(@Nullable Str resource_path)
      Sets the `GtkMediaFile 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].
      Parameters:
      resource_path - path to resource to play
    • setResource

      public void setResource(String resource_path)
      Sets the `GtkMediaFile 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].
      Parameters:
      resource_path - path to resource to play
    • asPaintable

      public Paintable asPaintable()
      Implements interface Paintable. Call this to get access to interface functions.
      Overrides:
      asPaintable in class MediaStream
      Returns:
      Paintable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()