Skip to content

Commit

Permalink
Update documentation for pillarbox-cast (#774)
Browse files Browse the repository at this point in the history
Co-authored-by: Joaquim Stähli <[email protected]>
  • Loading branch information
MGaetan89 and StaehliJ authored Nov 1, 2024
1 parent c4def7f commit fd8e6c9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 33 deletions.
9 changes: 0 additions & 9 deletions pillarbox-cast/Module.md

This file was deleted.

33 changes: 13 additions & 20 deletions pillarbox-cast/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
[![Pillarbox logo](https://github.com/SRGSSR/pillarbox-apple/blob/main/docs/README-images/logo.jpg)](https://github.com/SRGSSR/pillarbox-android)
[![Last release](https://img.shields.io/github/v/release/SRGSSR/pillarbox-android?label=Release)](https://github.com/SRGSSR/pillarbox-android/releases)
[![Android min SDK](https://img.shields.io/badge/Android-21%2B-34A853)](https://github.com/SRGSSR/pillarbox-android)
[![License](https://img.shields.io/github/license/SRGSSR/pillarbox-android?label=License)](https://github.com/SRGSSR/pillarbox-android/blob/main/LICENSE)
# Module pillarbox-cast

# Pillarbox Cast module

This module provides helpers to integrate cast with Pillarbox.
Provides helpers to integrate Cast with Pillarbox.

## Integration

```gradle
implementation("ch.srgssr.pillarbox:pillarbox-cast:$LATEST_RELEASE_VERSION")
```

More information can be found on the [top level README](../../docs/README.md)
To use this module, add the following dependency to your project's `build.gradle`/`build.gradle.kts` file:

## Documentation
- [Getting started](#getting-started)
- [Tracking](./MediaItemTracking.md)
- [Google Cast SDK](https://developers.google.com/cast/docs/android_sender)
## Known issues
- Nothing.
```kotlin
implementation("ch.srgssr.pillarbox:pillarbox-cast:<pillarbox_version>")
```

## Getting started

### Get the unique instance of CastContext.
### Get the `CastContext` instance

```kotlin
val castContext = context.getCastContext()
```
## Display the MediaRouteButton

### Display a Cast button

```kotlin
CastButton(modifier = Modifier)
```

## Additional resources

- [Google Cast SDK](https://developers.google.com/cast/docs/android_sender)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit fd8e6c9

Please sign in to comment.