- Media playback (audio, video)
- Change playback speed with time stretching (without affecting pitch)
- Continuous preview for timeline-like features
- Creation of snapshots by timestamps
- Coroutines/Flow based API
- Compose video rendering
graph TD
KlarityPlayer --> PlayerController
PlayerController --> Pipeline
PlayerController --> BufferLoop
PlayerController --> PlaybackLoop
PlayerController --> Settings
PlayerController --> PlayerState
PlayerController --> BufferTimestamp
PlayerController --> PlaybackTimestamp
PlayerController --> Renderer
PlayerController --> Events
BufferLoop --> Pipeline
PlaybackLoop --> BufferLoop
PlaybackLoop --> Pipeline
PlayerController --> Pipeline
subgraph Pipeline
Pipeline.AudioVideo --> Media
Pipeline.AudioVideo --> AudioDecoder
Pipeline.AudioVideo --> VideoDecoder
Pipeline.AudioVideo --> AudioBuffer
Pipeline.AudioVideo --> VideoBuffer
Pipeline.AudioVideo --> Sampler
Pipeline.AudioVideo --> Renderer
Pipeline.Audio --> Media
Pipeline.Audio --> AudioDecoder
Pipeline.Audio --> AudioBuffer
Pipeline.Audio --> Sampler
Pipeline.Video --> Media
Pipeline.Video --> VideoDecoder
Pipeline.Video --> VideoBuffer
Pipeline.Video --> Renderer
end
Sampler --> JNI\nNativeSampler --> C++\nSampler
AudioDecoder --> JNI\nNativeDecoder
VideoDecoder --> JNI\nNativeDecoder
JNI\nNativeDecoder --> C++\nDecoder
stateDiagram-v2
state PlayerState {
[*] --> Empty
Empty --> Preparing: Prepare Media
Preparing --> Ready: Media Ready
Preparing --> Empty: Release
state Ready {
[*] --> Stopped
Stopped --> Playing: Play
Playing --> Paused: Pause
Playing --> Stopped: Stop
Playing --> Seeking: SeekTo
Paused --> Playing: Resume
Paused --> Stopped: Stop
Paused --> Seeking: SeekTo
Stopped --> Completed: Playback Completed
Stopped --> Seeking: SeekTo
Completed --> Stopped: Stop
Completed --> Seeking: SeekTo
Seeking --> Seeking: SeekTo
Seeking --> Paused: Seek Completed
Seeking --> Stopped: Stop
}
Ready --> Empty: Release
}
Current State \ Target State | Empty | Preparing | Ready (Stopped) | Ready (Playing) | Ready (Paused) | Ready (Completed) | Ready (Seeking) | Released |
---|---|---|---|---|---|---|---|---|
Empty | N/A | Prepare | N/A | N/A | N/A | N/A | N/A | N/A |
Preparing | N/A | N/A | Media Ready | N/A | N/A | N/A | N/A | Release |
Ready (Stopped) | N/A | N/A | N/A | Play | N/A | N/A | SeekTo | Release |
Ready (Playing) | N/A | N/A | Stop | N/A | Pause | N/A | SeekTo | N/A |
Ready (Paused) | N/A | N/A | Stop | Resume | N/A | N/A | SeekTo | N/A |
Ready (Completed) | N/A | N/A | Stop | N/A | N/A | N/A | SeekTo | N/A |
Ready (Seeking) | N/A | N/A | Stop | N/A | Seek Completed | N/A | SeekTo | N/A |
Full list of formats supported by FFmpeg
Contains basic components such as: controller, player, preview manager, snapshot manager
Contains a Compose component for rendering video
Contains a demo application
To run demo application place the binaries appropriate to your platform into the example/bin
folder and run
the Application.
- KlarityPlayer - contains the media player logic.
- SnapshotManager - allows to get frames (snapshots) with a specified timestamp once per session. Use case - previewing keyframes.
- PreviewManager - allows to get frames ( snapshots) with a specific timestamp during a continuous session. Use case - previewing the timeline.
- Renderer - Provides functionality for rendering background and foreground.
- Load binaries using the Klarity loader object
Binaries must be located in the filesystem, however, they can be part of a jar - for this the binaries must be opened as temporary files whose path can be used by the loader.
- Use the necessary components