Skip to content

Android quick start

OGPlayer for Android is built on Media3/ExoPlayer with a Jetpack Compose player UI, distributed as AAR artifacts.

Requirements: Android 8.0+ (minSdk 26) · Kotlin 2.1+ · a Compose-enabled app for the UI module (ogplayer-core alone works from any Android app).

1 · Add the repository and the dependencies

Section titled “1 · Add the repository and the dependencies”

Android artifacts are served from the OGPlayer Maven repository. Add it to dependencyResolutionManagement in your settings file, after google() and mavenCentral() — the content filter keeps Gradle from asking it for anything outside the tv.ogplayer group:

settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://maven.ogplayer.tv") { content { includeGroup("tv.ogplayer") } }
}
}

Projects that still declare repositories per module (allprojects { repositories { … } } in the root build.gradle) add the same maven(…) line there instead.

Then the modules, in your app module:

app/build.gradle.kts
dependencies {
implementation("tv.ogplayer:ogplayer-core:<version>")
implementation("tv.ogplayer:ogplayer-ui:<version>")
// optional capabilities:
implementation("tv.ogplayer:ogplayer-ads-ima:<version>")
implementation("tv.ogplayer:ogplayer-cast:<version>")
}

Replace <version> with the current Android SDK version — 1.6.0 at the time of writing; the release notes always list the latest per platform. All tv.ogplayer modules in your app must share one version.

Media3 (which the SDK builds on) requires core-library desugaring in your app module:

android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
}
val player = OGPlayer.Builder(context)
.setLicenseKey("OGP2…") // omit → watermarked trial mode
.setAdsProvider(ImaAdsProvider(context)) // optional
.setCastConnector(OGCastConnector(context)) // optional
.build()
player.load(
OGMediaItem.Builder("https://example.com/stream.m3u8")
.setStreamType(StreamType.VOD)
.setTitle("My video")
.setDrm(
DrmConfig.Builder("https://license.example.com/widevine")
.setTokenProvider("X-DRM-Token") { tokenService.freshToken() }
.build(),
)
.setThumbnailTrack("https://example.com/storyboard.vtt")
.build(),
)

DRM tokens are fetched on every license request — never frozen at load time — so sessions survive long pauses and license expiry transparently (PlaybackListener.onDrmSessionRenewed).

OGPlayerView(
player = player,
uiConfig = OGUiConfig.Builder().build(),
fullscreenHandler = ActivityFullscreenHandler(activity),
overlays = mapOf(OverlaySlot.TOP_END to { MyWatermark() }),
)

Release the player with player.release() when the screen goes away.

player.addListener(object : PlaybackListener {
override fun onStateChanged(state: PlaybackState) { /* IDLE/BUFFERING/READY/ENDED */ }
override fun onError(error: OGPlayerError) { /* stable codes, see Error codes */ }
})
player.addAnalyticsListener { event -> analytics.track(event.toString()) }

Every guide in these docs has a matching screen in the open-source Android demo app — clone it and lift code from there.