Class MediaFile

All Implemented Interfaces:
Paintable, Proxy
Direct Known Subclasses:
MediaFile.MediaFile$Impl

@Generated("org.javagi.JavaGI") public abstract class MediaFile extends MediaStream implements 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.

  • Constructor Details

    • MediaFile

      public MediaFile(MemorySegment address)
      Create a MediaFile instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • MediaFile

      public MediaFile()
      Create a new MediaFile.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the MediaFile class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected MediaFile asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class MediaStream
      Returns:
      the instance as if it were its parent type
    • forFile

      public static MediaFile forFile(File file)
      Creates a new media file to play file.
      Parameters:
      file - The file to play
      Returns:
      a new GtkMediaFile playing file
    • forFilename

      public static MediaFile forFilename(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 forFile(File).

      Parameters:
      filename - filename to open
      Returns:
      a new GtkMediaFile playing filename
    • forInputStream

      public static MediaFile forInputStream(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
    • forResource

      public static MediaFile forResource(String resourcePath)

      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 forFile(File).

      Parameters:
      resourcePath - resource path to open
      Returns:
      a new GtkMediaFile playing resourcePath
    • clear

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

      public @Nullable File getFile()

      Returns the file that this MediaFile is currently playing from.

      When this MediaFile is not playing or not playing from a file, null is returned.

      Returns:
      The currently playing file
    • getInputStream

      public @Nullable InputStream getInputStream()

      Returns the stream that this MediaFile is currently playing from.

      When this MediaFile 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 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 setFile(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 String resourcePath)

      Sets the GtkMediaFile to play the given resource.

      This is a utility function that converts the given resourcePath to a GFile and calls setFile(File).

      Parameters:
      resourcePath - path to resource to play
    • close

      protected void close()
    • open

      protected void open()