YdPlayer - Advanced Android Video Library

A flexible, state-driven Android video library built on ExoPlayer. Simplifies complex media playback tasks like adaptive streaming, custom UIs, and lifecycle management.

KotlinExoPlayerHiltCoroutinesMVVM

YdPlayer: Simplifying High-Quality Media Playback

Project Type: Android Open Source Library
Role: Sole Creator & Maintainer
Tech Stack: Kotlin, Google ExoPlayer, Hilt, Coroutines


The Problem

Implementing a professional-grade video player in Android is surprisingly difficult. While Google's ExoPlayer provides the low-level building blocks, developers still need to manually manage playback state across Activity lifecycles, handle aspect ratio logic for different screen sizes, and build complex custom UI controllers from scratch.

For most app developers, these recurring implementation details are a bottleneck that diverts focus from their core product features. There was a need for a wrapper that provided a clean, high-level API while still allowing the full flexibility of the underlying ExoPlayer engine.


Technical Architecture

I architected YdPlayer using a State-Driven Model. Instead of imperative commands to the player, the library exposes a reactive state stream that reflects whether the player is buffering, playing, or stalled.

This state-driven approach ensures that the UI always matches the player's internal state, preventing the "UI/Player Mismatch" bugs that are common in many media apps. The library is built with MVVM principles in mind, making it easy to integrate into modern Android architectures.


Key Engineering Decisions

Adaptive Streaming by Default. I pre-configured the library to support DASH, HLS, and SmoothStreaming with adaptive bitrate switching. This ensures that users on poor networks still get a smooth experience without the developer having to write complex TrackSelection logic.

Seamless Lifecycle Integration. One of the biggest pain points in Android media is the proper release and restoration of the player during screen rotations or when the app goes into the background. I built a LifecycleObserver into the library's core component, automating the pause/resume/release cycle so developers don't have to worry about memory leaks or orphaned media sessions.

The "Plug-and-Play" UI. Instead of a rigid, one-size-fits-all controller, I implemented a modular UI system. Developers can either use the library's pre-built controllers (with light/dark/gradient themes) or provide their own custom layout file, which the library then automatically wires up to the underlying player logic.


Result and Impact

YdPlayer significantly lowered the barrier to entry for high-quality media on Android. It provided:

  • 80% Reduction in Boilerplate: Common playback tasks (e.g., fullscreen toggle, orientation handling) that previously took hundreds of lines are reduced to single API calls.
  • Robustness at Scale: By centralizing the complex state logic, the library eliminates a whole class of "illegal state" crashes that plague manual ExoPlayer implementations.
  • Developer Experience: A clean, Kotlin-first API that makes media playback as simple as displaying an image with Glide or Coil.

Future Improvements

As the Android ecosystem moves towards Jetpack Compose, my next step for YdPlayer is to release a native Compose-based UI layer that utilizes the latest state-management primitives.