Skip to content

Unable to connect Chrome cast in flutter app #47

@pavithraAndroid

Description

@pavithraAndroid

I Implemented Screen Casting using Default ID in flutter app but when i try to connect Chrome cast , I encountered issue mentioned below

  1. [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could either mean that the input has been truncated or that an embedded message misreported its own length.
format error invalid buffer exception

This is my MainActivity code :

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

manifest code :

Dart Code to connect chrome cast :

Future _connectToYourApp(BuildContext context, CastDevice object) async {
final session = await CastSessionManager().startSession(object);

session.stateStream.listen((state) {
  if (state == CastSessionState.connected) {
    final snackBar = SnackBar(content: Text('Connected'));
    ScaffoldMessenger.of(context).showSnackBar(snackBar);

    _sendMessageToYourApp(session);
  }
});

session.messageStream.listen((message) {
  print('receive message: $message');
});

session.sendMessage(CastSession.kNamespaceReceiver, {
  'type': 'LAUNCH',
  'appId': 'CC1AD845', 
});

}

help me to resolve this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions