
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
io.github.rufenkhokhar:KMP-Player
Advanced tools
KMPPlayer is a Kotlin Multiplatform media playback library that delivers a unified, reactive interface to control media playback across Android and iOS platforms. Internally, it leverages ExoPlayer on Android and AVPlayer on iOS, while exposing a clean Kotlin API usable from shared code and Jetpack Compose.
KMPPlayerState
)StateFlow
-based event stream (KMPPlayerEvent
)KMPPlayer
)destroy()
Published to Maven Central:
repositories {
mavenCentral()
}
For Kotlin Multiplatform (shared code):
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.rufenkhokhar:KMP-Player:+")
}
}
}
Or for Android-only usage:
dependencies {
implementation("io.github.rufenkhokhar:KMP-Player:+")
}
val playerState = rememberKMPPlayerState()
KMPPlayer(
state = playerState,
showControls = true,
modifier = Modifier
.fillMaxSize()
.background(Color.Black)
)
LaunchedEffect(Unit) {
// Load media
playerState.setFileUrl("https://www.sample-videos.com/video321/mp4/360/big_buck_bunny_360p_20mb.mp4")
// Configure playback
playerState.setVolume(0.8f) // 80% volume
playerState.setPlaybackSpeed(1.25f) // 1.25x speed
playerState.setVideoLoop(true) // enable looping
// Start playback
playerState.play()
// Observe playback events
playerState.observePlayerEvent().collect { event ->
when (event) {
is KMPPlayerEvent.Playing -> {
println("Playing: ${event.currentPosition} / ${event.duration}")
}
KMPPlayerEvent.Paused -> println("Paused")
KMPPlayerEvent.Stop -> println("Stopped")
KMPPlayerEvent.Buffering -> println("Buffering…")
KMPPlayerEvent.Ideal -> println("Idle")
KMPPlayerEvent.Ended -> println("Playback ended")
is KMPPlayerEvent.Error -> println("Error: ${event.message}")
}
}
}
KMPPlayerState
@ExperimentalMultiplatform
interface KMPPlayerState {
fun play()
fun stop()
fun pause()
fun isPlaying(): Boolean
fun setLocalFile(absolutePath: String)
fun setFileUrl(url: String)
fun setVideoLoop(loop: Boolean)
fun observePlayerEvent(): StateFlow<KMPPlayerEvent>
fun getPlatformPlayer(): Any?
fun destroy()
fun setVolume(volume: Float)
fun getVolume(): Float
fun setPlaybackSpeed(speed: Float)
fun getCurrentPosition(): Long
fun getDuration(): Long
fun seekTo(position: Long)
}
KMPPlayerEvent
sealed interface KMPPlayerEvent {
data class Playing(
val currentPosition: Long = 0L,
val duration: Long = 0L
) : KMPPlayerEvent
data object Paused : KMPPlayerEvent
data object Stop : KMPPlayerEvent
data object Buffering : KMPPlayerEvent
data object Ideal : KMPPlayerEvent
data object Ended : KMPPlayerEvent
data class Error(val message: String) : KMPPlayerEvent
}
setVideoLoop(true)
for infinite loopingsetVolume(0.0f–1.0f)
to control playback volumesetPlaybackSpeed(speed)
to adjust playback rategetCurrentPosition()
+ getDuration()
for progress trackingseekTo(ms)
to scrub or skipdestroy()
to release player resources when not in usegetPlatformPlayer()
and cast to native typesMIT License
© 2025 Rufen Khokhar
Pull requests and feature ideas are welcome!
Open an issue to start the discussion.
Rufen Khokhar
📧 rufankhokhar@gmail.com
🔗 github.com/rufenkhokhar
FAQs
Unknown package
We found that io.github.rufenkhokhar:KMP-Player demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.