KitePlayerJava
A KitePlayer for a Java app, on the JVM and Android (#394).
The player speaks in coroutines and flows, and a Java app can call neither. This adds what Java lacks, beside the Kotlin API rather than instead of it:
addListener and removeListener, for the state, the progress, the events and the warnings, called on an Executor the app names. An Android app passes its main executor.
A CompletableFuture version of every call that suspends, named with
Async. Cancelling the future cancels the call, as cancelling the coroutine does in Kotlin.Millisecond versions of the calls that take or give a kotlin.time.Duration, which Java cannot call by name.
Everything else is on player, whose other calls Java can make directly: play(), pause(), setVolume(float) and the rest. The data the player publishes has Java names for the values a player screen reads: Progress.positionMillis, PlayerSnapshot.durationMillis, PlayerEvent.SeekCompleted.landedAtMillis and Tracks.selectedTrack. Tracks are named by their TrackInfo here, because Java cannot read or make a TrackId.
KitePlayerJava player = KitePlayerJava.create();
player.addListener(listener, ContextCompat.getMainExecutor(context));
player.openAsync(new MediaItemBuilder("https://example.com/movie.mp4").build())
.thenRun(() -> player.getPlayer().play());This holds no state of the player's own. Every listener call comes from collecting the player's flows, and every future from launching its suspending call, so a future completes exactly once, with the answer the call gives.
Types
Properties
Functions
KitePlayer.addExternalSubtitle. Completes once the file's track shows, selected; it is then the subtitle track of Tracks.selectedTrack.
Calls listener on executor with the state, the progress, the events and the warnings, until removeListener. Adding a listener that is already added does nothing.
KitePlayer.attachRendererAndAwait.
KitePlayer.awaitClose. Completes once the player is asked to close, by anyone.
KitePlayer.captureFrame.
KitePlayer.chapterAt the position positionMillis.
KitePlayer.clearQueue.
KitePlayer.close: asks the player to close and returns at once. closeAsync completes when it has. Listeners stay until removeListener, so they hear the closing state.
KitePlayer.closeAndAwait. Completes once the player has closed and released everything.
KitePlayer.inspect.
KitePlayer.moveInQueue.
KitePlayer.next.
KitePlayer.nextChapter.
KitePlayer.openQueue.
KitePlayer.position, in milliseconds.
KitePlayer.previous.
KitePlayer.previousChapter.
KitePlayer.removeFromQueue.
Stops calling listener. Calls already handed to its executor are dropped; one that has already begun on another thread may still finish.
KitePlayer.requestSeek to positionMillis. Returns at once.
KitePlayer.restore, with a memento from KitePlayer.memento().
KitePlayer.scanAudio: decodes the sound of track of media, or of the track an open would pick for null, from fromMillis to untilMillis, and hands it to sink. Null bounds scan from the start or to the end.
KitePlayer.seek to positionMillis with mode. Completes once the player has landed there.
KitePlayer.seekToChapter.
KitePlayer.selectProgram: the channel numbered number, or the automatic choice for null.
KitePlayer.selectSecondarySubtitle: track, or none for null.
KitePlayer.selectVariant: the variant with index, or the automatic choice for null.
KitePlayer.setAudioDelay, in milliseconds.
KitePlayer.setSleepTimer, fading for fadeMillis. Make the timer with sleepAfter, sleepAt or SleepTimer.EndOfItem.INSTANCE, or pass null to clear it.
KitePlayer.setSubtitleDelay, in milliseconds.
KitePlayer.startRecording.
KitePlayer.stepFrame.
KitePlayer.stop.
KitePlayer.stopRecording.