terrabythia / dart_chromecast Goto Github PK
View Code? Open in Web Editor NEWDart package to play videos to a chromecast device
License: MIT License
Dart package to play videos to a chromecast device
License: MIT License
Original (Not working, /lib/casting/cast_sender.dart)
void setVolume(double volume) {
Map<String, dynamic> map = {'volume': min(volume, 1)};
_castMediaAction('VOLUME', map);
}
void _castMediaAction(type, [params]) {
if (null == params) params = {};
if (null != _mediaChannel && null != _castSession?.castMediaStatus) {
_mediaChannel.sendMessage(params
..addAll({
'mediaSessionId': _castSession.castMediaStatus.sessionId,
'type': type,
}));
}
}
Correction
level:
void setVolume(double volume) {
_receiverChannel.sendMessage({
"type": "SET_VOLUME",
"volume": {"level": volume}
});
}
mute:
void setMuted(bool mute) {
_receiverChannel.sendMessage({
"type": "SET_VOLUME",
"volume": {"muted": mute}
});
}
I am using audio_cast but the error seems to be from dart_chromecast , how can i fix this?
I/flutter (11728): [audio_cast] startDiscovery
I/flutter (11728): [audio_cast] startDiscovery
E/Dart (11728): Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_android.cc:147: reusePort
not supported for Android.
E/Dart (11728): Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_android.cc:147: reusePort
not supported for Android.
E/Dart (11728): Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_android.cc:147: reusePort
not supported for Android.
Hi, this is more a question than an issue, does this package support flutter web ? I know that mdns isn't working on web so I was wondering.
Thanks
I tried to cast screen using this plugin but it give me error.
class CastSender and method _createSocket()
OS Error: WRONG_VERSION_NUMBER(tls_record.cc:242)
Is it possible with the package 'camera' to cast my device camera stream in real-time?
Since Dart 1.12 dart_chromecast
does not pass static analysis on pub.dev.
This also applies to packages depending on this library and thus is crucial to me.
Hi, so I am trying to integrate Chromecast into my media player and noticed that my app cannot disconnect from the device no matter what state it is in. Calling CastSender.disconnect()
outputs this to the debug console:
I/flutter (16022): Send: protocolVersion: CASTV2_1_0
I/flutter (16022): sourceId: client-56436
I/flutter (16022): destinationId: 4da28398-839c-4e8e-8dbe-30b1cb7a73bf
I/flutter (16022): namespace: urn:x-cast:com.google.cast.media
I/flutter (16022): payloadType: STRING
I/flutter (16022): payloadUtf8: {"mediaSessionId":1,"type":"STOP","requestId":28}
I/flutter (16022): List: [0, 0, 0, 141, 8, 0, 18, 12, 99, 108, 105, 101, 110, 116, 45, 53, 54, 52, 51, 54, 26, 36, 52, 100, 97, 50, 56, 51, 57, 56, 45, 56, 51, 57, 99, 45, 52, 101, 56, 101, 45, 56, 100, 98, 101, 45, 51, 48, 98, 49, 99, 98, 55, 97, 55, 51, 98, 102, 34, 32, 117, 114, 110, 58, 120, 45, 99, 97, 115, 116, 58, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 97, 115, 116, 46, 109, 101, 100, 105, 97, 40, 0, 50, 49, 123, 34, 109, 101, 100, 105, 97, 83, 101, 115, 115, 105, 111, 110, 73, 100, 34, 58, 49, 44, 34, 116, 121, 112, 101, 34, 58, 34, 83, 84, 79, 80, 34, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 50, 56, 125]
I/flutter (16022): Send: protocolVersion: CASTV2_1_0
I/flutter (16022): sourceId: client-56436
I/flutter (16022): destinationId: 4da28398-839c-4e8e-8dbe-30b1cb7a73bf
I/flutter (16022): namespace: urn:x-cast:com.google.cast.tp.connection
I/flutter (16022): payloadType: STRING
I/flutter (16022): payloadUtf8: {"type":"STOP","sessionId":1,"requestId":29}
I/flutter (16022): List: [0, 0, 0, 144, 8, 0, 18, 12, 99, 108, 105, 101, 110, 116, 45, 53, 54, 52, 51, 54, 26, 36, 52, 100, 97, 50, 56, 51, 57, 56, 45, 56, 51, 57, 99, 45, 52, 101, 56, 101, 45, 56, 100, 98, 101, 45, 51, 48, 98, 49, 99, 98, 55, 97, 55, 51, 98, 102, 34, 40, 117, 114, 110, 58, 120, 45, 99, 97, 115, 116, 58, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 97, 115, 116, 46, 116, 112, 46, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 40, 0, 50, 44, 123, 34, 116, 121, 112, 101, 34, 58, 34, 83, 84, 79, 80, 34, 44, 34, 115, 101, 115, 115, 105, 111, 110, 73, 100, 34, 58, 49, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 50, 57, 125]
I/flutter (16022): PING
E/flutter (16022): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (16022): SocketException: Write failed (OS Error: Broken pipe, errno = 32), address = 192.168.0.129, port = 49166
E/flutter (16022): #0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
E/flutter (16022): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (16022): #2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (16022): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (16022): SocketException: Write failed (OS Error: Broken pipe, errno = 32), address = 192.168.0.129, port = 49166
E/flutter (16022): #0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
E/flutter (16022): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (16022): #2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Every other function (play/pause, seek, etc.) works fine. Stepping through, it gets caught on the sessionId
getter.
This is a very good library to play videos from flutter application to Chromecast. We are unable to find the way to play DRM content which has license for the video content. Is it possible to play DRM content with this library. If possible let us know the code clues.
Here is the sample code for playing DRM content with shaka player in web version. Adding this link just to refer the license passing for DRM content.
https://shaka-player-demo.appspot.com/docs/api/tutorial-license-server-auth.html
Hi,
I'm using the chromecast to display a web page and I need to be able to send custom message.
For this I need to create my own CastChannel with my own namespace and the destinationId should be the transporterId
like for the MediaChannel
.
I can do everything except accessing the _socket
property required to create the channel.
Not compatible with http: ^0.13.0
Original (Not working, /lib/casting/cast_media.dart)
Map toChromeCastMap() {
return {
'type': 'LOAD',
'autoPlay': autoPlay,
'currentTime': position,
'activeTracks': [],
'media': {
'contentId': contentId,
'contentType': contentType,
'images': images,
'title': title,
'streamType': 'BUFFERED',
}
};
}
Correction
Map toChromeCastMap() {
return {
'type': 'LOAD',
'autoPlay': autoPlay,
'currentTime': position,
'activeTracks': [],
'media': {
'contentId': contentId,
'contentType': contentType,
'metadata': {
'metadataType': 0,
'images': images,
'title': title,
'subtitle': subtitle
},
'streamType': 'BUFFERED',
}
};
}
Trying to use this library but having an issue when trying to get a CastDevice
CastDevice device = CastDevice(name:info.name,host: info.address,port:info.port,type: '_googlecast._tcp');
This gives me the error:
Invalid argument(s): "<" expected at 1:1
#0 parse (package:xml/xml.dart:43:5)
#1 new CastDevice.<anonymous closure> (package:dart_chromecast/casting/cast_device.dart:33:36)
#2 _RootZone.runUnary (dart:async/zone.dart:1379:54)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
#5 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
#6 Future._complete (dart:async/future_impl.dart:476:7)
#7 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#8 _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
#9 _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:295:13)
#10 _withClient (package:http/http.dart)
<asynchronous suspension>
#11 get (package:http/http.dart:46:5)
Any ideas?
When attempting to run the provided index.dart on Dart version 2.10.2 on Windows*, I get an exception:
Command:
dart example/index.dart http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4
Result:
Looking for ChromeCast devices...
Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_win.cc:194: `reusePort` not supported for Windows.Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_win.cc:194: `reusePort` not supported for Windows.Unhandled exception:
SocketException: Failed to create datagram socket (OS Error: The requested address is not valid in its context.
, errno = 10049), address = , port = 5353
#0 _NativeSocket.bindDatagram (dart:io-patch/socket_patch.dart:798:7)
<asynchronous suspension>
#1 _RawDatagramSocket.bind (dart:io-patch/socket_patch.dart:2155:26)
#2 RawDatagramSocket.bind (dart:io-patch/socket_patch.dart:2113:31)
#3 MDnsClient.start (package:multicast_dns/multicast_dns.dart:127:71)
<asynchronous suspension>
#4 find_chromecasts (package:dart_chromecast/utils/mdns_find_chromecast.dart:19:16)
...
(* current latest provided with Flutter SDK. I'm not making an Android/iOS app in this case, just REPLing with dart_chromecast. I'm curious if I'd hit a similar issue on Android, though.)
The funcion find_chromecast.find_chromecasts() is not able to return any device in network, and trow an error :
"Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_android.cc:147: reusePort
not supported for Android."
The error can be fixed adding rawDatagramSocketFactory to MDnsClient() but it stills not returning any device.
My code:
@override
void initState() {
findCastingDevices();
super.initState();
}
Future<void> findCastingDevices() async {
// search!
print('Looking for ChromeCast devices...');
devices = (await find_chromecast.find_chromecasts()).cast<find_chromecast.CastDevice>();
if (devices.length == 0) {
print('No devices found!');
Future.delayed(Duration(seconds: 45), () {
findCastingDevices();
});
return;
}
print("Found ${devices.length} devices:");
for (int i = 0; i < devices.length; i++) {
int index = i + 1;
find_chromecast.CastDevice device = devices[i];
print("$index: ${device.name}");
}
setState(() {});
}
Is it possible to mirror/cast app screen on the chromecast device using this package?
Hi,
it doesnt seem to be working on iOS. Searching for devices returns no results
Compiler message:
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:16:7: Error: The non-abstract class 'CastMessage' is missing implementations for these members:
class CastMessage extends GeneratedMessage {
^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:85:7: Error: The non-abstract class '_ReadonlyCastMessage' is missing implementations for these members:
class _ReadonlyCastMessage extends CastMessage with ReadonlyMessageMixin {}
^^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:87:7: Error: The non-abstract class 'AuthChallenge' is missing implementations for these members:
class AuthChallenge extends GeneratedMessage {
^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:109:7: Error: The non-abstract class '_ReadonlyAuthChallenge' is missing implementations for these members:
class _ReadonlyAuthChallenge extends AuthChallenge with ReadonlyMessageMixin {}
^^^^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:111:7: Error: The non-abstract class 'AuthResponse' is missing implementations for these members:
class AuthResponse extends GeneratedMessage {
^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:147:7: Error: The non-abstract class '_ReadonlyAuthResponse' is missing implementations for these members:
class _ReadonlyAuthResponse extends AuthResponse with ReadonlyMessageMixin {}
^^^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:149:7: Error: The non-abstract class 'AuthError' is missing implementations for these members:
class AuthError extends GeneratedMessage {
^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:176:7: Error: The non-abstract class '_ReadonlyAuthError' is missing implementations for these members:
class _ReadonlyAuthError extends AuthError with ReadonlyMessageMixin {}
^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:178:7: Error: The non-abstract class 'DeviceAuthMessage' is missing implementations for these members:
class DeviceAuthMessage extends GeneratedMessage {
^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/git/dart_chromecast-7a9e5ab973a8e387b81923f8a4483a23a49f2b61/lib/proto/cast_channel.pb.dart:217:7: Error: The non-abstract class '_ReadonlyDeviceAuthMessage' is missing implementations for these members:
class _ReadonlyDeviceAuthMessage extends DeviceAuthMessage with ReadonlyMessageMixin {
^^^^^^^^^^^^^^^^^^^^^^^^^^
file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/protobuf-0.13.4/lib/src/protobuf/generated_message.dart:52:20: Context: 'GeneratedMessage.createEmptyInstance' is defined here.
GeneratedMessage createEmptyInstance();
^^^^^^^^^^^^^^^^^^^
Compiler terminated unexpectedly.
Moving to null safety
should be top priority.
Without support for null safety
this package will not get new users as everybody is moving to it.
It is stopping me from using this package and I am sure it is not just me.
Hi, thanks for publishing this great plugin, I'm using in my streaming app called FarmTUBE (free). The only issue is the friendly name comes back "Unknown" on iPhones/iPads . It still streams fine, it's just an issue selecting the correct device in a house with multiple Chromecasts. I've tested a number of apple phones at different houses with the same result, it works perfectly on Android devices.
I'm using a gen2 Chromecast (i have many of them)
I would be willing to pay £50 for a fix to this bug as casting is the primary purpose of my app.
Thanks
Stuart
Can I screenshare an app from the mobile to the Chromecast with this ?
You only mention casting videos in the readme
Thanks !
This is a request to add support for null safety to this package.
See the migration guide for details about enabling null safety.
The example is using a .mp4 video that can be found on a public URL.
Is there a way to open web pages or youtube videos by sending URLs?
We getting fewer points on basic staff that we can easily improve.
For example to get the static analysis
points we just need to run dart format .
.
In the Provide documentation
section we missing the example section which exists and we just need to show it correctly for pub.dev.
And there are more.
If needed I will be happy to try getting more points.
hi please is there anyway to send request headers like user agent or cookie ?
There is a breaking change in the protobuf plugin that dart_chromecast depends on.
Latest version supported is protobuf: 0.13.16+1
using setVolume doesn't work.
Hi,
Thank you so much for this awesome plugin. I was just wondering if it is possible to change playback speed of the casted audio/video? I couldn't find it anywhere in the code.
Thanks!
On our pub.dev score page it is written that the package's version is not up to date.
let's update and increase our pub.dev score.
I cannot run flutter, since the old flutter_svg package (v 0.17) produces errors on the newest version of flutter: 1.20.1.
But I can't upgrade the package to 0.18, since it requires xml ^4.1.0, and dart_chromecast 0.1.2 depends on xml ^3.0.0 and it is not possible to use the xml ^4.1.0 because of this.
Is it possible for me to manually override what this package depends on?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.