https://github.com/gianlucaparadise/flutter_cast_framework
Google Cast SDK for flutter
https://github.com/gianlucaparadise/flutter_cast_framework
android chromecast flutter flutter-plugin ios
Last synced: 5 months ago
JSON representation
Google Cast SDK for flutter
- Host: GitHub
- URL: https://github.com/gianlucaparadise/flutter_cast_framework
- Owner: gianlucaparadise
- License: apache-2.0
- Created: 2019-11-05T22:04:03.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-15T16:17:26.000Z (over 2 years ago)
- Last Synced: 2025-05-07T02:29:35.228Z (5 months ago)
- Topics: android, chromecast, flutter, flutter-plugin, ios
- Language: Dart
- Homepage: https://gianlucaparadise.github.io/flutter_cast_framework/api/
- Size: 913 KB
- Stars: 23
- Watchers: 5
- Forks: 17
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Flutter Cast Framework
## Overview

Flutter Cast Framework is a POC of a flutter plugin that lets you use Chromecast API in a flutter app.
## Useful links
* [Repository](https://github.com/gianlucaparadise/flutter_cast_framework)
* [API Docs](https://gianlucaparadise.github.io/flutter_cast_framework/api/)## Exposed APIs
Currently only the following APIs are integrated (both Android and iOS):
* Cast State
* Session state
* Send custom message
* Listen to received custom messages
* Load RemoteMediaRequestData
* Play, Pause, Stop media
* Expanded controls
* Mini Controller
* Cast Button
* Chromecast connection## Setup
#### Add Dependency
Run the following to add `flutter_cast_framework` to the dependencies:
```shell
flutter pub add flutter_cast_framework
```### 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.SessionProviderclass CastOptionsProvider : OptionsProvider {
override fun getCastOptions(context: Context): CastOptions {
return CastOptions.Builder()
.setReceiverApplicationId("4F8B3483") // Your receiver Application ID
.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)).
### iOS Setup
#### 1. Minimum iOS version
Make sure you minimum iOS version is 10.0.
Select *Runner* from left pane > *General* tab > *Deployment Info* > *Target*: set 10.0 or higher#### 2. Install iOS dependencies
When Xcode is closed, open a terminal at the root folder of your project and run:
```bash
cd ios && pod install
```#### 3. Open project in Xcode
To open your flutter project with Xcode, from root folder run `open ios/Runner.xcworkspace`
#### 4. Chromecast SDK setup
Add the following lines to your `AppDelegate.swift`:
```diff
import UIKit
import Flutter
+import GoogleCast
@UIApplicationMain
-@objc class AppDelegate: FlutterAppDelegate {
+@objc class AppDelegate: FlutterAppDelegate, GCKLoggerDelegate {
+ let kReceiverAppID = "4F8B3483" // Your receiver Application ID
+ let kDebugLoggingEnabled = true
+
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
+ let criteria = GCKDiscoveryCriteria(applicationID: kReceiverAppID)
+ let options = GCKCastOptions(discoveryCriteria: criteria)
+ GCKCastContext.setSharedInstanceWith(options)
+
+ // Enable logger.
+ GCKLogger.sharedInstance().delegate = self
+
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
+
+ // MARK: - GCKLoggerDelegate
+
+ func logMessage(_ message: String,
+ at level: GCKLoggerLevel,
+ fromFunction function: String,
+ location: String) {
+ if (kDebugLoggingEnabled) {
+ print(function + " - " + message)
+ }
+ }
}
```## 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## Roadmap
Next features to be developed:
* CC in Expanded Controls (iOS)
* Expanded Controls cosmetics (ad in progress bar, full screen, progress bar handle)
* Title in MiniController and ExpandedControls (blocked because of a [pigeon issue](https://github.com/flutter/flutter/issues/93464), but solved with a workaround)
* Handle queue
* Handle progress seek
* Understand if it is better to refactor using streams instead of listeners
* Add tests
* Various glitches and cosmetic fixes