Class MediaFile
- Direct Known Subclasses:
MediaFile.MediaFile$Impl
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMediaFile.Builder<B extends MediaFile.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe MediaFile$Impl type represents a native instance of the abstract MediaFile class.static classNested classes/interfaces inherited from class MediaStream
MediaStream.MediaStream$Impl, MediaStream.MediaStreamClassNested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface Paintable
Paintable.InvalidateContentsCallback, Paintable.InvalidateSizeCallback, Paintable.Paintable$Impl, Paintable.PaintableInterface -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new MediaFile.MediaFile(MemorySegment address) Create a MediaFile instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected MediaFileasParent()Return this instance as if it were its parent type.voidclear()Resets the media file to be empty.protected voidclose()static MediaFileCreates a new media file to playfile.static MediaFileforFilename(String filename) Creates a new media file for the given filename.static MediaFileforInputStream(InputStream stream) Creates a new media file to playstream.static MediaFileforResource(String resourcePath) Creates a new new media file for the given resource.@Nullable FilegetFile()Returns the file that this MediaFile is currently playing from.@Nullable InputStreamReturns the stream that this MediaFile is currently playing from.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the MediaFile class.protected voidopen()voidSets theGtkMediaFileto play the given file.voidsetFilename(@Nullable String filename) Sets theGtkMediaFileto play the given file.voidsetInputStream(@Nullable InputStream stream) Sets theGtkMediaFileto play the given stream.voidsetResource(@Nullable String resourcePath) Sets theGtkMediaFileto play the given resource.Methods inherited from class 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, updateAudioMethods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, 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, 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, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Paintable
computeConcreteSize, emitInvalidateContents, emitInvalidateSize, getCurrentImage, getFlags, getIntrinsicAspectRatio, getIntrinsicHeight, getIntrinsicWidth, invalidateContents, invalidateSize, onInvalidateContents, onInvalidateSize, snapshot
-
Constructor Details
-
MediaFile
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
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code.- Overrides:
asParentin classMediaStream- Returns:
- the instance as if it were its parent type
-
forFile
-
forFilename
Creates a new media file for the given filename.
This is a utility function that converts the given
filenameto aGFileand callsforFile(File).- Parameters:
filename- filename to open- Returns:
- a new
GtkMediaFileplayingfilename
-
forInputStream
Creates a new media file to play
stream.If you want the resulting media to be seekable, the stream should implement the
GSeekableinterface.- 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
resourceto aGFileand callsforFile(File).- Parameters:
resourcePath- resource path to open- Returns:
- a new
GtkMediaFileplayingresourcePath
-
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,
nullis 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,
nullis returned.- Returns:
- The currently playing stream
-
setFile
Sets the
GtkMediaFileto play the given file.If any file is still playing, stop playing it.
- Parameters:
file- the file to play
-
setFilename
Sets the
GtkMediaFileto play the given file.This is a utility function that converts the given
filenameto aGFileand callssetFile(File).- Parameters:
filename- name of file to play
-
setInputStream
Sets the
GtkMediaFileto play the given stream.If anything is still playing, stop playing it.
Full control about the
streamis assumed for the duration of playback. The stream will not be closed.- Parameters:
stream- the stream to play from
-
setResource
Sets the
GtkMediaFileto play the given resource.This is a utility function that converts the given
resourcePathto aGFileand callssetFile(File).- Parameters:
resourcePath- path to resource to play
-
close
protected void close() -
open
protected void open()
-