numq / Klarity

Jetpack Compose desktop media player library
Apache License 2.0
9 stars 0 forks source link
audio compose desktop ffmpeg jetpack jni klarity kotlin library media multimedia pitch playback player portaudio shift stretching time video

Klarity

logo

Media player loader for Jetpack Compose Desktop

screenshot

Table of Content

Features

Architecture

Dependency graph

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

State diagram

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
    }

Transition table

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

Supported formats

Full list of formats supported by FFmpeg

Modules

Core

Contains basic components such as: controller, player, preview manager, snapshot manager

Dependencies

Compose

Contains a Compose component for rendering video

Dependencies

Example

Contains a demo application

Dependencies

To run demo application place the binaries appropriate to your platform into the example/bin folder and run the Application.

Components

Usage