5 Commits

Author SHA1 Message Date
jbibik
c3313c0049 Add jvmTarget and kotlin-android plugin to common_ktx module
According to https://kotlinlang.org/docs/gradle-configure-project.html#check-for-jvm-target-compatibility-of-related-compile-tasks and https://kotlinlang.org/docs/gradle-configure-project.html#what-can-go-wrong-if-targets-are-incompatible, we require explicit jvmTarget setting in order not to run into:

`'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.`

Missing the plugin and the jvmTarget resulted in a failed `compileDebugKotlin` task for any application code, which was trying to import common_ktx functions (e.g. `Player.listen` with `Unresolved reference: listen` error)

PiperOrigin-RevId: 663358677
2024-08-15 10:36:10 -07:00
ibaker
873ec1544e Remove nested import of Player.Events from PlayerExtensions.listen
This makes it clearer that the part inside and outside the parentheses
are clearly different, and not "just" a reference to `Player.Events`.
Specifically this syntax is showing that the function has a `Player`
"receiver", **and** is a function from `Player.Events` to `Unit`.

https://kotlinlang.org/docs/lambdas.html#function-types

PiperOrigin-RevId: 663293405
2024-08-15 07:07:48 -07:00
ibaker
ef6cb5d913 Use runCatching instead of try/catch in PlayerExtensionsTest
PiperOrigin-RevId: 661992546
2024-08-12 01:44:53 -07:00
jbibik
9ace81bf2f Move PlayerExtensions into common-ktx module
For now, the only extension function on the `Player` has been used in a Compose demo. It can be promoted to a proper module where in the future other extension functions will reside. Given that `Player` is in `androidx.media3.common`, the corresponding KTX library for it is `androidx.media3.common-ktx`

To start using the new `suspend fun listen`, one must add `androidx.media3:media3-common-ktx` as a Gradle dependency and `import androidx.media3.common.listen`

PiperOrigin-RevId: 658771029
2024-08-02 06:24:10 -07:00
jbibik
018d0488e1 Create a new media3-common-ktx module
It will be used for Kotlin-specific functionality like extension functions on the classes from the `media3-common` module. To import it, add the following to your build.gradle file:

`implementation("androidx.media3:media3-common-ktx:1.X.Y")`

PiperOrigin-RevId: 658492256
2024-08-01 12:14:16 -07:00