A sample demonstrating how to use Picture-in-Picture (PiP) mode with OptiView Player (formerly THEOplayer), allowing video playback to continue in a floating window.
The app combines the player's PiP API with native Android PiP APIs and the AndroidX
VideoPlaybackPictureInPicture helper for a fully native PiP experience:
- Auto-enter PiP when navigating away (API 31+),
- Manual PiP trigger via a toolbar button,
- Play/pause
RemoteActions shown as overlay buttons in the PiP window, - Dynamic aspect ratio that stays in sync with the video dimensions,
- Background playback so that the audio continues while in PiP
Please refer to Android's guide on PiP for more information on native PiP capabilities.
- Open this repository in Android Studio.
- Select the
pip-handlingrun configuration. - Build and run on a device or emulator.
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)
implementation(libs.theoplayer.ui)
}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.
Video sources are defined in SourceManager.
This project is licensed under the BSD 3 Clause License - see the LICENSE file for details.