搜索插件、代码仓与 APP 分类

插件详情v0.3.3

dart_chromecast

纯 Dart 包,用于将视频投射到您的 ChromeCast 设备并控制其播放

AndroidiOSmacOSWindowsLinux
近 30 天下载
146
喜欢数
51
Pub 分数
140

安装插件

flutter pub add dart_chromecast

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个纯 Dart 包,可无缝将视频投射到 ChromeCast 设备,并提供完整的播放控制。它提供了一个简单的 API,用于发现、连接并管理跨多个平台的 Chromecast 设备上的媒体播放。非常适合需要集成 Google 投射生态系统但不依赖于特定平台代码的应用程序。该包支持 Android、iOS、macOS、Windows 和 Linux,使其在跨平台开发中具有高度灵活性。

适合场景

  • 从移动或桌面应用程序投射视频
  • 远程控制播放
  • 构建媒体流应用
  • 在Flutter应用中集成Chromecast支持
  • 启用多设备媒体同步

主要特点

  • 跨平台兼容性
  • 用于投射和播放的简单 API
  • 支持媒体元数据和播放控制
  • 实时设备发现
  • 内置的错误处理和连接管理

适合对象

  • 开发媒体应用的开发者
  • 需要远程播放控制的应用
  • 跨平台电视和流媒体解决方案
  • Flutter 项目针对多个操作系统

使用建议

  • 需要兼容的 Chromecast 设备
  • 网络配置可能会影响连接性
  • 仅限视频投射(不支持音频仅投射)
  • 在某些平台上可能需要额外的权限
  • 依赖稳定的网络条件以实现可靠的投射

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

dart_chromecast

Dart package to play videos to a chromecast device. Pub.dev package: https://pub.dev/packages/dart_chromecast

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.

Update 0.2.0: added MDNS finder, you can now omit the --host parameter and it will ask you which chromecast to use


Find the IP address of your chromecast on mac OS

This is the way I found the IP address of my ChromeCast on my Mac. This is not guaranteed to work for everyone, but if it helps anyone, here are the terminal commands:

$ dns-sd -B _googlecast local

Copy the instance name

$ dns-sd -L <IntanceName> _googlecast._tcp. local.

Copy the name (without the port) directly after the text ' can be reached at '...

$ dns-sd -Gv4v6 <Paste>


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


usage

options

media space separated list of one or more media source urls

host (optional) 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 example/main.dart <media> [--host <host> [--port <port> [--append [ --debug]]]]

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 example/main.dart http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerFun.mp4

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 example/main.dart --host=192.168.1.1

所属分类

依赖

依赖清单 8 项

源码仓库

使用此插件的项目