Custom Surface Rendering
March 4, 2026 ยท View on GitHub
A sample demonstrating how to render OptiView Player (formerly THEOplayer) on custom surfaces, including SurfaceView, TextureView, and SurfaceControl (API 29+).
PlayerActivity uses XML DataBinding
with buttons to switch between SurfaceView, TextureView, and SurfaceControl rendering targets.
CustomSurfaceView and CustomTextureView implement proper surface callbacks, while AspectRatioHelper
handles aspect ratio calculations for FIT and ASPECT_FILL modes.
Quick Start
- Open this repository in Android Studio.
- Select the
custom-surface-renderingrun configuration. - Build and run on a device or emulator.
THEOplayer dependency
This project uses THEOplayer from the official Maven repository.
The repository is declared in the project-level settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven { url = uri("https://maven.theoplayer.com/releases") }
}
}
Dependencies are managed through a version catalog and declared
in the module-level build.gradle.kts:
dependencies {
implementation(libs.theoplayer)
}
License key
To play your own streams, add a THEOplayer license from the THEOportal in
common/src/main/res/values/values.xml:
<string name="theoplayer_license">YOUR_LICENSE_HERE</string>
The license is picked up automatically via the <meta-data> tag in
AndroidManifest.xml.
Streams
Video sources are defined in SourceManager.
License
This project is licensed under the BSD 3 Clause License - see the LICENSE file for details.