dart_chromecast 0.1.0

dart_chromecast #

Dart package to play videos to a chromecast device

This package is currently under development and not ready for real use! The API will most likely change completely. Also no guarantees of this project working at all until it has its first stable release.

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.

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=192.168.1.1

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=192.168.1.1

Use this package as a library

1. Depend on it

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


dependencies:
  dart_chromecast: ^0.1.0

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/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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
95
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
40
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Nov 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Health suggestions

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

Analysis of lib/casting/cast_sender.dart reported 6 hints, including:

line 34 col 9: The value of the field '_heartbeatTimer' isn't used.

line 35 col 9: The value of the field '_receiverStatusTimer' isn't used.

line 140 col 51: Use = to separate a named parameter from its default value.

line 321 col 42: Use isNotEmpty instead of length

line 331 col 34: Use isEmpty instead of length

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

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

line 1 col 8: Unused import: 'dart:async'.

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

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

line 58 col 5: Don't explicitly initialize variables to null.

Fix additional 13 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • 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_media.dart (Run dartfmt to format lib/casting/cast_media.dart.)
  • lib/casting/cast_media_status.dart (Run dartfmt to format lib/casting/cast_media_status.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/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.pbjson.dart (Run dartfmt to format lib/proto/cast_channel.pbjson.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.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (protobuf).

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.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+2
logging ^0.11.3+2 0.11.3+2
observable ^0.22.2 0.22.2
protobuf ^0.13.11 0.13.16+1 1.0.1
xml ^3.0.0 3.5.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
dart_internal 0.1.7
fixnum 0.10.11
http_parser 3.1.3
matcher 0.12.6
meta 1.1.8
path 1.6.4
pedantic 1.8.0+1
petitparser 2.4.0
quiver 2.1.2+1
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6