
I originally tried switching to `Futures.addCallback` (as a follow-up to Issue: androidx/media#890), but it seemed like a good chance to go further into Kotlin-ification. Before this change, if the connection to the session failed, the app would hang at the 'waiting' screen with nothing logged (and the music keeps playing). This behaviour is maintained with the `try/catch` around the `.await()` call (with additional logging). Without this, the failed connection causes the `PlayerActivity` to crash and the music in the background stops. The `try/catch` is used to flag to developers who might be using this app as an example that connecting to the session may fail, and they may want to handle that. This change also switches `this.controller` to be `lateinit` instead of nullable. Issue: androidx/media#890 PiperOrigin-RevId: 638948568
Demos
This directory contains apps that demonstrate how to use Android media modules, like ExoPlayer. Browse the individual demos and their READMEs to learn more.
Running a demo
From Android Studio
- File -> New -> Import Project -> Specify the root
media
folder. - Choose the demo from the run configuration dropdown list.
- Click Run.
Using gradle from the command line:
- Open a Terminal window at the root
media
folder. - Run
./gradlew projects
to show all projects. Demo projects start withdemo
. - Run
./gradlew :<demo name>:tasks
to view the list of available tasks for the demo project. Choose an install option from theInstall tasks
section. - Run
./gradlew :<demo name>:<install task>
.
For example, ./gradlew :demo:installNoDecoderExtensionsDebug
installs the
ExoPlayer demo app in debug mode with no optional modules.