| 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 |
Integrating a native .so library into a Kotlin Multiplatform project requires bridging the Android-specific native code with your shared Kotlin logic. kmp external codec libvlcjni.so
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 | Aspect | libvlcjni
: You can use video conversion tools to change the audio track to a more standard format like AAC or MP3, which KMPlayer can play without external help. Download KMPlayer Custom Codec kmp external codec libvlcjni.so
: Tap Initialize App or restart the player to apply the changes. Troubleshooting for Modern (64-bit) Devices
expect class MediaEngine fun play(url: String) fun pause() fun stop() fun release()
// commonMain/kotlin/MediaPlayer.kt expect class PlatformMediaPlayer() fun setDataSource(path: String) fun play() fun stop() fun isPlaying(): Boolean