JavaFxVideoTexture

class JavaFxVideoTexture(val mediaUrl: String, width: Int, height: Int) : CallbackVideoTexture, VideoPlayback

JVM video texture driven by JavaFX MediaPlayer. JavaFX has no per-frame callback API, so we host the MediaView in an off-screen Scene (no javafx.stage.Stage attached) and snapshot the view on every JavaFX AnimationTimer pulse — that's the standard idiom for "give me the current video frame as pixels".

The snapshot returns a WritableImage; we read its pixels in PixelFormat.getByteBgraInstance format into a heap byte array and forward to the CallbackVideoTexture base. The GL thread uploads on the next bind.

Runtime requirement: OpenJFX 21+ runtime JARs (javafx-base, javafx-graphics, javafx-media, javafx-swing) with the host platform classifier on the module path — JavaFX rejects classpath loads since JDK 9.

Constructors

Link copied to clipboard
constructor(mediaUrl: String, width: Int, height: Int)

Properties

Link copied to clipboard
Link copied to clipboard
val coordTransform: Matrix3
Link copied to clipboard

Caller opt-out for mipmap generation.

Link copied to clipboard
val height: Int
Link copied to clipboard

Filesystem path or URL to the media. A bare path is wrapped via File.toURI.

Link copied to clipboard
val target: Int
Link copied to clipboard
open override val timeMs: Long

Current playback time in milliseconds since playback started.

Link copied to clipboard
val width: Int

Functions

Link copied to clipboard
open override fun bindTexture(dc: DrawContext): Boolean
Link copied to clipboard
fun getTexParameter(name: Int): Int
Link copied to clipboard
fun getTextureName(dc: DrawContext): KglTexture
Link copied to clipboard
open override fun pause()

Pause playback. The current frame stays on the texture; resumable via play.

Link copied to clipboard
open override fun play()

Start (or resume) playback. Re-entrant — calling on an already-running player is a no-op.

Link copied to clipboard
open override fun release(dc: DrawContext)

Frees any resources associated with this instance. After this method returns the rendering resource is invalid, and any associated GL object is deleted.

open override fun release()

Free decoder + native resources. After release the texture is unusable.

Link copied to clipboard
fun setTexParameter(name: Int, param: Int)
Link copied to clipboard
open override fun stop()

Stop playback and rewind to the start.