dart_chromecast 0.1.2

dart_chromecast #

Dart package to play videos to a chromecast device

This package is currently under development and the API can change completely at some point. Use at your own risk.

Simplified port of https://github.com/thibauts/node-castv2-client.

Originally designed to work in Flutter with the flutter_mdns_plugin https://github.com/terrabythia/flutter_mdns_plugin, so this cli project does not include a mdns browser, you should find out what the local ip address and port of your ChromeCast is yourself.

See https://github.com/terrabythia/flutter_chromecast_example for an example implementation in Flutter of both the flutter_mdns_plugin and this repository.

options #

media space separated list of one or more media source urls

host IP address of a ChromeCast device in the same network that you are on.

port (optional) port of the ChromeCast device. Defaults to 8009.

flags #

--append (-a) whether to append the passed in media to the current playlist and not replace the current playlist (if reconnecting was successful). Defaults to false.
--debug (-d) whether to show all info logs, defaults to false.

usage #

dart index.dart <media> --host <host> --port <port> [--append]

playback control #

In this demo the following keys can be used to control the playback of the video:

space toggle paused state
s stop playback
esc disconnect device
left arrow key seek -10 seconds
right arrow key seek +10 seconds

example #

dart index.dart http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4 --debug --host=

reconnecting to active session #

When you exit the command line without disconnecting the device, the video will keep playing. To reconnect without messing with the current playlist, just run the command without any media urls. Eg:

dart index.dart --host=

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_chromecast: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dart_chromecast/casting/cast.dart';
import 'package:dart_chromecast/casting/cast_channel.dart';
import 'package:dart_chromecast/casting/cast_device.dart';
import 'package:dart_chromecast/casting/cast_media.dart';
import 'package:dart_chromecast/casting/cast_media_status.dart';
import 'package:dart_chromecast/casting/cast_sender.dart';
import 'package:dart_chromecast/casting/cast_session.dart';
import 'package:dart_chromecast/casting/connection_channel.dart';
import 'package:dart_chromecast/casting/heartbeat_channel.dart';
import 'package:dart_chromecast/casting/interfaces/log_interface.dart';
import 'package:dart_chromecast/casting/media_channel.dart';
import 'package:dart_chromecast/casting/receiver_channel.dart';
import 'package:dart_chromecast/proto/cast_channel.pb.dart';
import 'package:dart_chromecast/proto/cast_channel.pbenum.dart';
import 'package:dart_chromecast/proto/cast_channel.pbjson.dart';
import 'package:dart_chromecast/proto/cast_channel.pbserver.dart';
import 'package:dart_chromecast/writer.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/proto/cast_channel.pbjson.dart. (-16.51 points)

Analysis of lib/proto/cast_channel.pbjson.dart reported 36 hints, including:

line 8 col 26: Avoid const keyword.

line 10 col 8: Avoid const keyword.

line 11 col 5: Avoid const keyword.

line 12 col 5: Avoid const keyword.

line 13 col 5: Avoid const keyword.

Fix lib/casting/cast_sender.dart. (-1.99 points)

Analysis of lib/casting/cast_sender.dart reported 4 hints:

line 19 col 8: Unused import: 'package:dart_chromecast/casting/interfaces/log_interface.dart'.

line 23 col 22: Unnecessary new keyword.

line 387 col 3: The method doesn't override an inherited method.

line 393 col 3: The method doesn't override an inherited method.

Fix lib/casting/cast_device.dart. (-0.50 points)

Analysis of lib/casting/cast_device.dart reported 1 hint:

line 29 col 22: Unnecessary new keyword.

Fix additional 14 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/casting/cast_media_status.dart (1 hint)
  • lib/casting/heartbeat_channel.dart (1 hint)
  • lib/casting/receiver_channel.dart (1 hint)
  • lib/casting/cast.dart (Run dartfmt to format lib/casting/cast.dart.)
  • lib/casting/cast_channel.dart (Run dartfmt to format lib/casting/cast_channel.dart.)
  • lib/casting/cast_media.dart (Run dartfmt to format lib/casting/cast_media.dart.)
  • lib/casting/cast_session.dart (Run dartfmt to format lib/casting/cast_session.dart.)
  • lib/casting/connection_channel.dart (Run dartfmt to format lib/casting/connection_channel.dart.)
  • lib/casting/interfaces/log_interface.dart (Run dartfmt to format lib/casting/interfaces/log_interface.dart.)
  • lib/casting/media_channel.dart (Run dartfmt to format lib/casting/media_channel.dart.)
  • lib/proto/cast_channel.pb.dart (Run dartfmt to format lib/proto/cast_channel.pb.dart.)
  • lib/proto/cast_channel.pbenum.dart (Run dartfmt to format lib/proto/cast_channel.pbenum.dart.)
  • lib/proto/cast_channel.pbserver.dart (Run dartfmt to format lib/proto/cast_channel.pbserver.dart.)
  • lib/writer.dart (Run dartfmt to format lib/writer.dart.)

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_chromecast.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
args ^1.4.0 1.5.2
cli_util ^0.1.3+2 0.1.3+2
http ^0.12.0+2 0.12.0+4
logging ^0.11.3+2 0.11.4
observable ^0.22.2 0.22.2
protobuf >=1.0.1 <2.0.0 1.0.1
protoc_plugin ^19.0.1 19.0.1
xml ^3.0.0 3.7.0
Transitive dependencies
_fe_analyzer_shared 1.0.3
analyzer 0.39.4
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_internal 0.1.8
dart_style 1.3.3
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
http_parser 3.1.3
js 0.6.1+1
matcher 0.12.6
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pedantic 1.9.0
petitparser 3.0.0
pub_semver 1.4.2
quiver 2.1.2+1
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0