Google Cast SDK for flutter
Find a file
gianlucaparadise 9dc03055de iOS: Initial CAF setup;
CastState handling;
CastButton press handling;
2019-11-19 06:10:10 +01:00
.vscode vscode setup 2019-11-07 07:35:36 +01:00
android Fix CastIcon wrong state on creation 2019-11-18 06:10:27 +01:00
assets Basic CastButton implementation; 2019-11-09 10:00:49 +01:00
example iOS: Initial CAF setup; 2019-11-19 06:10:10 +01:00
ios iOS: Initial CAF setup; 2019-11-19 06:10:10 +01:00
lib CastIcon color handling 2019-11-18 06:10:45 +01:00
test Initial CastContext setup; 2019-11-08 06:52:35 +01:00
.gitignore updated flutter 2019-11-07 07:35:17 +01:00
.metadata Initial commit 2019-11-07 07:33:27 +01:00
CHANGELOG.md Initial commit 2019-11-07 07:33:27 +01:00
flutter_cast_framework.iml iOS: Initial CAF setup; 2019-11-19 06:10:10 +01:00
LICENSE Initial commit 2019-11-07 07:33:27 +01:00
pubspec.lock Basic CastButton implementation; 2019-11-09 10:00:49 +01:00
pubspec.yaml Basic CastButton implementation; 2019-11-09 10:00:49 +01:00
README.md Readme updated 2019-11-18 06:09:15 +01:00

Flutter Cast Framework

Overview

Flutter Cast Framework is a POC of a flutter plugin that lets you use Chromecast API in a flutter app.

Exposed APIs

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

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:

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<SessionProvider>? {
        return null
    }
}

2. Load CastOptionsProvider

Add the following entry in the AndroidManifest.xml file under the <application> tag to reference the CastOptionsProvider class:

<application>
    <meta-data
        android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
        android:value="com.gianlucaparadise.flutter_cast_framework_example.CastOptionsProvider" />
</application>

3. Theme

Make sure that your application and your activity are using an AppCompat theme (as stated here).

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