diff --git a/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/CastExtensions.kt b/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/CastExtensions.kt index 42454dcae..31c67fea6 100644 --- a/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/CastExtensions.kt +++ b/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/CastExtensions.kt @@ -9,9 +9,15 @@ import com.google.android.gms.cast.framework.CastContext import com.google.common.util.concurrent.MoreExecutors /** - * Get the shared instance of [CastContext] if available, or initialize a new one. - * Call this method inside your [Activity][android.app.Activity] or [Application][android.app.Application]. - * The sooner, the better. + * Retrieves the shared instance of [CastContext]. + * + * This function attempts to retrieve the existing shared instance of [CastContext]. If it doesn't exist, it initializes a new instance and returns + * it. + * + * Call this method inside your [Activity][android.app.Activity] or [Application][android.app.Application] for early initialization. The earlier this + * is called, the better the user experience. + * + * @return The shared instance of [CastContext]. */ fun Context.getCastContext(): CastContext { return CastContext.getSharedInstance() ?: CastContext.getSharedInstance(this, MoreExecutors.directExecutor()).result diff --git a/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/widget/CastButton.kt b/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/widget/CastButton.kt index 545a6d5d3..34be68144 100644 --- a/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/widget/CastButton.kt +++ b/pillarbox-cast/src/main/java/ch/srgssr/pillarbox/cast/widget/CastButton.kt @@ -4,6 +4,8 @@ */ package ch.srgssr.pillarbox.cast.widget +import android.app.Activity +import android.app.Application import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.viewinterop.AndroidView @@ -12,7 +14,13 @@ import com.google.android.gms.cast.framework.CastButtonFactory import com.google.android.gms.cast.framework.CastContext /** - * Make sure to instantiate a [CastContext] before using it. + * A composable function that displays a Cast button. This button allows users to discover and connect to Cast-enabled devices. + * + * You must instantiate a [CastContext] before using this composable. This is typically done in your [Activity] or [Application] class. + * + * @param modifier The [Modifier] to be applied to the Cast button. + * + * @see [Context.getCastContext()][ch.srgssr.pillarbox.cast.getCastContext] */ @Composable fun CastButton(