Class MediaFile
- Direct Known Subclasses:
MediaFile.MediaFileImpl
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
MediaFile.Builder<B extends MediaFile.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static class
The MediaFileImpl type represents a native instance of the abstract MediaFile class.Nested classes/interfaces inherited from class org.gnome.gtk.MediaStream
MediaStream.MediaStreamClass, MediaStream.MediaStreamImpl
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gdk.Paintable
Paintable.InvalidateContentsCallback, Paintable.InvalidateSizeCallback, Paintable.PaintableImpl, Paintable.PaintableInterface
-
Constructor Summary
ConstructorDescriptionCreates a new empty media file.MediaFile
(MemorySegment address) Create a MediaFile proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected MediaFile
asParent()
Returns this instance as if it were its parent type.static MediaFile.Builder
<? extends MediaFile.Builder> builder()
AMediaFile.Builder
object constructs aMediaFile
with the specified properties.void
clear()
Resets the media file to be empty.protected void
close()
static MediaFile
Creates a new media file to playfile
.static MediaFile
forFilename
(String filename) Creates a new media file for the given filename.static MediaFile
forInputStream
(InputStream stream) Creates a new media file to playstream
.static MediaFile
forResource
(String resourcePath) Creates a new new media file for the given resource.getFile()
Returns the file that this MediaFile is currently playing from.Returns the stream that this MediaFile is currently playing from.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the MediaFile classprotected void
open()
void
Sets theGtkMediaFile
to play the given file.void
setFilename
(@Nullable String filename) Sets theGtkMediaFile to play the given file. This is a utility function that converts the given @filename to a
GFile` and callssetFile(org.gnome.gio.File)
.void
setInputStream
(@Nullable InputStream stream) Sets theGtkMediaFile
to play the given stream.void
setResource
(@Nullable String resourcePath) Sets theGtkMediaFile to play the given resource. This is a utility function that converts the given @resource_path to a
GFile` and callssetFile(org.gnome.gio.File)
.Methods inherited from class org.gnome.gtk.MediaStream
ended, error, gerror, getDuration, getEnded, getError, getLoop, getMuted, getPlaying, getTimestamp, getVolume, hasAudio, hasVideo, isPrepared, isSeekable, isSeeking, pause, play, prepared, realize, seek, seekFailed, seekSuccess, setLoop, setMuted, setPlaying, setVolume, streamEnded, streamPrepared, streamUnprepared, unprepared, unrealize, update, updateAudio
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gdk.Paintable
computeConcreteSize, emitInvalidateContents, emitInvalidateSize, getCurrentImage, getFlags, getIntrinsicAspectRatio, getIntrinsicHeight, getIntrinsicWidth, invalidateContents, invalidateSize, onInvalidateContents, onInvalidateSize, snapshot
-
Constructor Details
-
MediaFile
Create a MediaFile proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
MediaFile
public MediaFile()Creates a new empty media file.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type.- Overrides:
asParent
in classMediaStream
-
forFile
-
forFilename
Creates a new media file for the given filename.This is a utility function that converts the given
filename
to aGFile
and callsforFile(org.gnome.gio.File)
.- Parameters:
filename
- filename to open- Returns:
- a new
GtkMediaFile
playingfilename
-
forInputStream
Creates a new media file to playstream
.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
Creates a new new media file for the given resource.This is a utility function that converts the given
resource
to aGFile
and callsforFile(org.gnome.gio.File)
.- Parameters:
resourcePath
- resource path to open- Returns:
- a new
GtkMediaFile
playingresourcePath
-
clear
public void clear()Resets the media file to be empty. -
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
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
Sets theGtkMediaFile
to play the given file.If any file is still playing, stop playing it.
- Parameters:
file
- the file to play
-
setFilename
Sets theGtkMediaFile to play the given file. This is a utility function that converts the given @filename to a
GFile` and callssetFile(org.gnome.gio.File)
.- Parameters:
filename
- name of file to play
-
setInputStream
Sets theGtkMediaFile
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
Sets theGtkMediaFile to play the given resource. This is a utility function that converts the given @resource_path to a
GFile` and callssetFile(org.gnome.gio.File)
.- Parameters:
resourcePath
- path to resource to play
-
close
protected void close() -
open
protected void open() -
builder
AMediaFile.Builder
object constructs aMediaFile
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withMediaFile.Builder.build()
.
-