How thereprator/kvideo-player works
Project Type & Purpose
• This is a Kotlin Multiplatform library + sample-app suite for playing HLS, DASH, and SmoothStreaming media across Web (JS & WASM), Desktop (JVM + bundled VLC), Android (phone/tablet/Auto/TV/Wear/XR), iOS, and tvOS.
• The goal is to expose a common playback API (KMP-player), a common Compose-based UI (player-ui), plus platform wrappers (Android modules, Swift xcframework) and sample applications that consume them.
File Structure
• Top-level modules:
• framework/KMP-player – the core KMP playback engine
• framework/player-ui – a Compose-based, multiplatform UI abstraction
• framework/AppleKMPVideoPlayer – a Swift/xcframework wrapper around AVFoundation for iOS/tvOS
• framework/android/* – Android-Auto, TV, Wear modules that wire in KMP-player + player-ui
• sample/* – sample apps per platform consuming the published artifacts
• Build & deployment:
• Gradle Kotlin-DSL (.kts) for orchestrating MPP source sets (commonMain, androidMain, iosMain, jsMain, etc.)
• Swift Package manifest (Package.swift) and xcframework for iOS
• Pre-bundled VLC binaries under desktopMain/resources/appResources
Pull Insights from the README
• Supported platforms: Kotlin/WASM, JS, Desktop (JVM+VLC), Android (phone/Auto/TV/Wear/XR), iOS, Apple TV
• External dependencies: Video.js (web playback), Hamamas HTML-Interop (WASM), VLC binaries (desktop), AVPlayer (iOS), ExoPlayer or Android’s media APIs
• Architectural principle: one common interface + multiple platform-specific implementations, published as artifacts and consumed by UI and sample apps.
a. Main Components
• Core Playback Engine (KMP-player/commonMain)
• Platform Implementations (KMP-player/androidMain, appleMain, desktopMain, jsMain, wasmJsMain, webMain)
• UI Abstraction (player-ui/commonMain) + Platform UI Views (androidMain, desktopMain, iosMain, webMain)
• iOS Swift Wrapper (AppleKMPVideoPlayer/xcframework)
• Desktop VLC Binaries (desktopMain/resources/appResources/...)
• Sample Applications (sample/src, sample/android, sample/ios, sample/AppleTVPlayer)
b. Interactions & Data Flow
• Samples ➔ UI module: sample app invokes VideoScreen (Compose)
• UI module ➔ Core engine: calls VideoPlayer interface (init/play/pause/ dispose)
• Core engine ➔ Platform impl: dispatches to VideoPlayerImplAndroid, PlaybackStateControllerImplIos, VideoPlayerImplWeb, VideoPlayerImplJvm
• Platform impl ➔ Native API:
• Android: ExoPlayer/Media APIs
• iOS: AVPlayer via Swift xcframework
• Desktop: libVLC via bundled binaries
• Web: HTML5 <video> or Video.js via WASM-JS interop
• Build system: Gradle compiles each source set into artifacts, SPM bundles the xcframework, Gradle assembles sample apps.
c. Architectural Patterns & Principles
• Layered design: UI → core API → platform implementation → native media engine
• Abstraction via Interfaces in commonMain, Implementations in platform source sets
• Multi-module Gradle project with shared settings.gradle.kts and libs.versions.toml
• Pre-bundled native binaries for desktop to avoid external dependencies
d. Key Technologies & Libraries
• Kotlin Multiplatform (common/Android/iOS/JS/Native source sets)
• Jetpack Compose Multiplatform (player-ui)
• Swift Package Manager + xcframework (AppleKMPVideoPlayer)
• Video.js & Kotlin-WASM-HTML-Interop (web)
• VLC (desktop)
• Android Auto/TV/Wear/XR UI modules