Player

The library provides a Kotlin Multiplatform wrapper for the native Aurora OS media player. It supports video/audio playback with OpenGL texture rendering, track selection (audio/video), software decode override, mute, auto-repeat, and event-driven state/position/duration/buffering reporting.

Dependency libraries

  • streamcamera

Features

  • Playback control: Load media by URI, play, pause, resume, seek, stop, and release.
  • Preview: Render the video stream in Compose UI using the ready-to-use PlayerViewfinder or a custom Canvas via drawFrame().
  • Tracks: Select audio/video tracks by ID (IDs come from the mediaInfo event). Subtitles are not supported by the backend and are filtered out before reaching Kotlin.
  • Software decode: Force software video decode globally (demotes the hardware droidvdec codec). Call before creating a player. Reversible.
  • Mute: Mute or unmute audio (no volume control — the streamcamera API exposes only mute).
  • Auto-repeat: Enable or disable loop.
  • Events: State, position, duration, buffering, media info, tracks selected, video size, and errors — all delivered via SharedFlow.
  • Rendering: OpenGL texture upload + Skia, with pixel-aspect-ratio-correct cover scaling (no rotation — decoded video is already oriented).
  • Codec info: Query device video codec capabilities via a static method.

Events

Each AuroraPlayer instance exposes the following SharedFlows:

Flow Type Description
errors PlayerErrorData Player errors
state PlayerState Player lifecycle state (Empty, Loading, Playing, etc.)
position ULong Playback position in microseconds
duration ULong Media duration in microseconds
buffering Int Buffering percentage (0–100, or -1)
mediaInfo MediaInfoData URI + list of available tracks (audio, video)
tracksSelected List<Int> Confirmation of the currently selected track IDs
videoSize VideoSizeData Frame dimensions and pixel aspect ratio

Example

// 1. Create a player instance
val player = AuroraPlayer()

// 2. Load and start playback
player.playUri("file:///home/defaultuser/Videos/sample.mp4")

// 3. Show video in Compose UI
PlayerViewfinder(player, modifier = Modifier.fillMaxSize())

// 4. Observe playback state, position, and duration
player.state.collect { state -> /* Playing / Paused / Eos / Empty */ }
player.position.collect { pos -> /* microseconds */ }
player.duration.collect { dur -> /* microseconds */ }

// 5. Select an audio track (IDs from the mediaInfo flow)
player.mediaInfo.collect { info ->
    val audio = info.tracks.firstOrNull { it.trackType == TrackType.Audio }
    audio?.let { player.selectTracks(listOf(it.id)) }
}

// 6. Control playback
player.pause()
player.play()                     // resume
player.seek(5_000_000uL)          // seek to 5s (ULong literal)
player.setMute(true)

// 7. Cleanup
player.stop()
player.release()                  // free native handle and GL resources