This paper is structured as a technical brief suitable for developers integrating advanced playback capabilities into KMP applications (Android/iOS/Desktop). 1. Introduction Kotlin Multiplatform (KMP) allows sharing business logic across Android, iOS, and Desktop JVM targets. However, media playback with support for proprietary or less common codecs (e.g., E-AC-3, DTS, RV40, some MPEG-4 variants) remains a challenge because native platform players (ExoPlayer, AVFoundation, MediaPlayer) rely on system codecs.
On Android, the libvlcjni.so ‑backed player will output audio correctly, whereas ExoPlayer would fail with No decoder for: audio/ac3 . libvlcjni.so provides KMP developers with a powerful, unified way to handle external codecs that are absent from platform decoders. By wrapping VLC’s engine in a KMP expect/actual pattern, you can achieve cross-platform playback with near‑identical behavior and extensive format support. kmp external codec libvlcjni.so
libvlc: using decoder module "avcodec" avcodec: using FFmpeg decoder for codec 'eac3' | Aspect | libvlcjni.so (Software) | MediaCodec (Hardware) | |--------|------------------------|------------------------| | CPU usage | High for 4K/HEVC | Low (GPU/DSP) | | Codec support | Full (hundreds) | Limited by device | | External codecs | Yes (built-in) | Rarely | | KMP compatibility | Works on Android, Linux, Windows | Android-only | This paper is structured as a technical brief
Actual implementation:
actual fun setDataSource(path: String) val options = arrayOf("--codec=all", "--no-audio-time-stretch") libVLC = LibVLC(ApplicationProvider.getApplicationContext(), options) mediaPlayer = MediaPlayer(libVLC) val media = Media(libVLC, path) media.addOption(":no-audio-filter") // optional mediaPlayer.media = media However, media playback with support for proprietary or