diff --git a/README.md b/README.md index ae66b32..925a66b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,80 @@ -# flutter_cast_framework +# Flutter Cast Framework -A new flutter plugin project. +## Overview -## Getting Started +Flutter Cast Framework is a POC of a flutter plugin that lets you use Chromecast API in a flutter app. -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. +## Exposed APIs -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +Currently only the following APIs are integrated: + +* Android: + * Cast State + * Session state + * Send custom message + * Listen to received custom messages + * Cast Button + * Chromecast connection +* iOS: + * Not implemented yet + +## Setup + +#### Add Dependency + +Clone this repo and add the following piece of code to your app's pubspec + +```yaml +dependencies: + flutter_cast_framework: + path: ../flutter_cast_framework/ # the path depends on where you cloned this repo +``` + +### Android Setup + +#### 1. Create `CastOptionsProvider` + +Add the following class to your Android project: + +```kotlin +import android.content.Context +import com.google.android.gms.cast.framework.CastOptions +import com.google.android.gms.cast.framework.OptionsProvider +import com.google.android.gms.cast.framework.SessionProvider + +class CastOptionsProvider : OptionsProvider { + override fun getCastOptions(context: Context): CastOptions { + return CastOptions.Builder() + .setReceiverApplicationId("4F8B3483") + .build() + } + + override fun getAdditionalSessionProviders(context: Context): List? { + return null + } +} +``` + +#### 2. Load `CastOptionsProvider` + +Add the following entry in the `AndroidManifest.xml` file under the `` tag to reference the `CastOptionsProvider` class: + +```xml + + + +``` + +#### 3. Theme + +Make sure that your application and your activity are using an `AppCompat` theme (as stated [here](https://developers.google.com/cast/docs/android_sender/integrate#androidtheme)). + +## Tech notes + +I used this project to test the capabilities of the following technologies: + +* Chromecast API (Sender - Android SDK) +* Flutter +* Flutter custom platform-specific code \ No newline at end of file diff --git a/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/cast/DefaultCastOptionsProvider.kt b/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/cast/DefaultCastOptionsProvider.kt index 03c16de..aad02ec 100644 --- a/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/cast/DefaultCastOptionsProvider.kt +++ b/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/cast/DefaultCastOptionsProvider.kt @@ -10,6 +10,8 @@ import com.google.android.gms.cast.framework.SessionProvider * This is here to be used as an example */ class DefaultCastOptionsProvider : OptionsProvider { + // TODO: find a way to build this from dart code. Maybe source_gen? + override fun getCastOptions(context: Context): CastOptions { return CastOptions.Builder() .setReceiverApplicationId("4F8B3483")