In this repository you will find several tech demos that use the JW Player SDK for Android
Refer to the README in each subdirectory for specific usage instructions.
- FullscreenWithoutRotationDemo - A
JWPlayerViewwith a customFullscreenHandlerthat goes fullscreen without rotating the screen - LocalAssetPlayback - Plays video, poster and captions bundled in the app's
assetsfolder - JWCompose - The player inside Jetpack Compose (
AndroidView), kept across recomposition and configuration changes
- AdvancedPlayerDemo - Custom native controls (play/pause, seek, playback rate, quality, ad badge and skip) with the SDK UI turned off, plus a VAST pre-roll and mid-roll schedule
- CustomUi - Replacing one of the SDK's UI groups (Next Up) with your own Kotlin view, using the SDK's UI view models
- CustomFragmentUi - A custom player view hosted in a
Fragment, with a small event log - StylingDemo - Restyling the player's controls by overriding the SDK's resources (colors, dimensions, styles)
- ImaAdCompanions - Google IMA ads with companion ad slots
- GoogleDAIDemo - Google IMA Dynamic Ad Insertion (DAI) for video on demand
- (VAST schedules are shown in AdvancedPlayerDemo)
- CaptionsDemo - Sideloaded and in-manifest captions, caption styling and position (
CaptionsConfig,CaptionPosition) and a track picker - PipDemo - Picture-in-picture: entering from a button or on Home, the PiP events and warnings, and pausing when the PiP window is closed
- VerticalFeedDemo - A full-screen vertical video feed (swipe up / down, one video per page) built on
ViewPager2with a fixed pool of three players; the README explains the limits of running several players at once - RecyclerViewDemo - Several players in a
RecyclerView: one plays at a time, players are reused with the views, and fullscreen moves the player out of its cell - ChromecastDemo - Casting with the JW Player Chromecast module
- BackgroundAudioDemo - Background audio with the SDK's own media session, notification and lock-screen controls, custom notification buttons and the optional SDK audio-focus handling (SDK 4.28.0+). The recommended way to add background audio
- notifications-demo - Background audio with an app-owned media session and
Notification, for apps that need full control of them
- DrmDemo - Online Widevine DRM with a licence URL (
DrmConfig), or a customMediaDrmCallback - OfflineDownloadsDemo - Offline downloads, including DRM, managed by the SDK (
OfflineDownloadManager). The recommended way to add offline playback - OfflineDelegateDemo - Offline downloads, including DRM, through the app's own Media3 download service and the SDK's
OfflineDelegatehook
In general the following usage instructions apply to most sample projects:
- Clone this repository
- Start up Android Studio choose Open an Existing Android Studio Project
- Navigate to the location of the repository and select the root directory of the app you want to load.
- Click OK
- Give the app your license key (use one option below).
BuildConfig.JWPLAYER_LICENSE_KEYis generated at build time, so it cannot be changed from code.- set the
JWPLAYER_LICENSE_KEYenvironment variable before building (Android Studio must be started from a shell that has it, or set it in your Gradle run configuration) - put your key in the app's
app/build.gradle(app/build.gradle.ktsin CustomUi) - pass your key directly to
LicenseUtil().setLicenseKey(context, "<your license key>")in the app's Activity
- set the
- OfflineDownloadsDemo also needs a JW Platform v1 API secret, read from the
JWPLAYER_V1_API_SECRETenvironment variable (see its README) - Click Run
For more information about the JW Player SDK for Android, and how to use it, head over to our Developer Portal
./buildAll.sh builds every sample (each folder with its own settings.gradle or settings.gradle.kts) with assembleDebug; pass another Gradle task to change that, e.g. ./buildAll.sh assembleRelease.