mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

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