Class Video

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public class Video extends Widget implements Accessible, Buildable, ConstraintTarget

Shows a GtkMediaStream with media controls.

An example GtkVideo

The controls are available separately as MediaControls. If you just want to display a video without controls, you can treat it like any other paintable and for example put it into a Picture.

GtkVideo aims to cover use cases such as previews, embedded animations, etc. It supports autoplay, looping, and simple media controls. It does not have support for video overlays, multichannel audio, device selection, or input. If you are writing a full-fledged video player, you may want to use the Paintable API and a media framework such as Gstreamer directly.

  • Constructor Details

    • Video

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

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

    • getType

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

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

      protected Video 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 Widget
      Returns:
      the instance as if it were its parent type
    • forFile

      public static Video forFile(@Nullable File file)
      Creates a GtkVideo to play back the given file.
      Parameters:
      file - a GFile
      Returns:
      a new GtkVideo
    • forFilename

      public static Video forFilename(@Nullable String filename)

      Creates a GtkVideo to play back the given filename.

      This is a utility function that calls forFile(File), See that function for details.

      Parameters:
      filename - filename to play back
      Returns:
      a new GtkVideo
    • forMediaStream

      public static Video forMediaStream(@Nullable MediaStream stream)
      Creates a GtkVideo to play back the given stream.
      Parameters:
      stream - a GtkMediaStream
      Returns:
      a new GtkVideo
    • forResource

      public static Video forResource(@Nullable String resourcePath)

      Creates a GtkVideo to play back the resource at the given resourcePath.

      This is a utility function that calls forFile(File).

      Parameters:
      resourcePath - resource path to play back
      Returns:
      a new GtkVideo
    • getAutoplay

      public boolean getAutoplay()
      Returns true if videos have been set to loop.
      Returns:
      true if streams should autoplay
    • getFile

      public @Nullable File getFile()
      Gets the file played by this Video or null if not playing back a file.
      Returns:
      The file played by this Video
    • getGraphicsOffload

      public GraphicsOffloadEnabled getGraphicsOffload()

      Returns whether graphics offload is enabled.

      See GraphicsOffload for more information on graphics offload.

      Returns:
      the graphics offload status
      Since:
      4.14
    • getLoop

      public boolean getLoop()
      Returns true if videos have been set to loop.
      Returns:
      true if streams should loop
    • getMediaStream

      public @Nullable MediaStream getMediaStream()
      Gets the media stream managed by this Video or null if none.
      Returns:
      The media stream managed by this Video
    • setAutoplay

      public void setAutoplay(boolean autoplay)
      Sets whether this Video automatically starts playback when it becomes visible or when a new file gets loaded.
      Parameters:
      autoplay - whether media streams should autoplay
    • setFile

      public void setFile(@Nullable File file)
      Makes this Video play the given file.
      Parameters:
      file - the file to play
    • setFilename

      public void setFilename(@Nullable String filename)

      Makes this Video play the given filename.

      This is a utility function that calls gtk_video_set_file(),

      Parameters:
      filename - the filename to play
    • setGraphicsOffload

      public void setGraphicsOffload(GraphicsOffloadEnabled enabled)

      Sets whether to enable graphics offload.

      See GraphicsOffload for more information on graphics offload.

      Parameters:
      enabled - the new graphics offload status
      Since:
      4.14
    • setLoop

      public void setLoop(boolean loop)
      Sets whether new files loaded by this Video should be set to loop.
      Parameters:
      loop - whether media streams should loop
    • setMediaStream

      public void setMediaStream(@Nullable MediaStream stream)

      Sets the media stream to be played back.

      this Video will take full control of managing the media stream. If you want to manage a media stream yourself, consider using a Picture for display.

      If you want to display a file, consider using setFile(File) instead.

      Parameters:
      stream - The media stream to play or null to unset
    • setResource

      public void setResource(@Nullable String resourcePath)

      Makes this Video play the resource at the given resourcePath.

      This is a utility function that calls setFile(File).

      Parameters:
      resourcePath - the resource to set
    • builder

      public static Video.Builder<? extends Video.Builder> builder()
      A Video.Builder object constructs a Video with the specified properties. Use the various set...() methods to set properties, and finish construction with Video.Builder.build().
      Returns:
      the builder object