Chromecast
Casting requires some extra steps to setup.
You need a receiver app ID. Recommend starting with the receiver code at https://github.com/bcc-code/bccm-player-chromecast, as it includes support for default languages (see "App config" docs). That receiver is also available at this appId for testing: 519C9F80
.
Android
- Change your android FlutterActivity to be a FlutterFragmentActivity (required for the native chromecast views):
// android/app/src/main/kotlin/your/bundle/name/MainActivity.kt
- class MainActivity : FlutterActivity() {
+ class MainActivity : FlutterFragmentActivity() {
- Add a cast_app_id to your AndroidManifest.xml
- Update
NormalTheme
in yourstyles.xml
to use an AppCompat theme and have acolorPrimary
. This is a requirement from the Cast SDK.
<style name="NormalTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> <!-- Change to use "AppCompat" -->
<item name="android:windowBackground">?android:colorBackground</item> <!-- This was already there -->
<item name="colorPrimary">#ffffffff</item> <!-- Added -->
</style>
- Update
NormalTheme
in yournight/styles.xml
too:
<style name="NormalTheme" parent="@style/Theme.AppCompat.NoActionBar"> <!-- Note there's no "Light" -->
<item name="android:windowBackground">?android:colorBackground</item>
<item name="colorPrimary">#ffffffff</item> <!-- Added -->
</style>
iOS
- Follow the cast sdk documentation on how to add the "NSBonjourServices" and "NSLocalNetworkUsageDescription" plist values: https://developers.google.com/cast/docs/ios_sender#ios_14
- Add your receiver id to your Info.plist:
- Example Info.plist for step 4 and 5:
<key>cast_app_id</key>
<string>519C9F80</string>
<key>NSLocalNetworkUsageDescription</key>
<string>${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi
network.</string>
<key>NSBonjourServices</key>
<array>
<string>_519C9F80._googlecast._tcp</string>
<string>_googlecast._tcp</string>
</array>