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

插件详情v1.0.3

flutter_video_cast

flutter_video_cast 让您发现 Chromecast 和 Apple TV 等投屏设备并连接到它们。

近 30 天下载
34
喜欢数
50
Pub 分数
40

安装插件

flutter pub add flutter_video_cast

插件介绍

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

flutter_video_cast 是一个 Flutter 包,可实现对 Chromecast 和 Apple TV 等投屏设备的发现和连接。它允许用户从其 Flutter 应用程序向兼容的显示设备流式传输视频内容,从而增强在智能电视和流媒体硬件之间的媒体共享。该包可无缝集成到现有的 Flutter 项目中,并支持设备检测和会话管理。对于希望将播放扩展到大屏幕的媒体类应用开发者而言,这是一个理想选择。

适合场景

  • 将流媒体视频传输到智能电视
  • 远程播放控制
  • 从移动应用进行媒体投射
  • 实时视频镜像
  • 多设备兼容
  • 跨平台投射

主要特点

  • 设备发现
  • 投射会话管理
  • 对 Chrome Cast 和 Apple TV 的支持
  • 与 Flutter 的简单集成
  • 实时设备状态更新
  • 跨平台功能

适合对象

  • 媒体和娱乐应用
  • 智能家居集成
  • 视频会议工具
  • 教育内容平台
  • 物联网设备控制器
  • 需要屏幕镜像的应用程序

使用建议

  • 需要兼容的投屏设备
  • 网络连接必不可少
  • 仅限支持的平台
  • 可能需要额外权限
  • 依赖外部 SDK
  • 无内置媒体播放器

原始 README

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

flutter_video_cast

A Flutter plugin for iOS and Android for connecting to cast devices like Chromecast and Apple TV.

Installation

First, add flutter_video_cast as a dependency in your pubspec.yaml file.

iOS

Set the minimum os target to iOS 11.0.

Initialize the Cast context in the application delegate ios/Runner/AppDelegate.m:

import UIKit
import Flutter
import GoogleCast

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, GCKLoggerDelegate {
    let kReceiverAppID = kGCKDefaultMediaReceiverApplicationID
    let kDebugLoggingEnabled = true

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        GeneratedPluginRegistrant.register(with: self)
        let criteria = GCKDiscoveryCriteria(applicationID: kReceiverAppID)
        let options = GCKCastOptions(discoveryCriteria: criteria)
        GCKCastContext.setSharedInstanceWith(options)
        GCKCastContext.sharedInstance().useDefaultExpandedMediaControls = true
        GCKLogger.sharedInstance().delegate = self
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

Android

Add dependencies in your module (app-level) Gradle file (usually android/app/build.gradle):

implementation 'com.google.android.gms:play-services-cast-framework:19.0.0'
implementation 'com.google.android.exoplayer:extension-cast:2.11.5'

Set the theme of the MainActivity to @style/Theme.AppCompat.NoActionBar in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
               android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider"/>
    ...
    <activity android:theme="@style/Theme.AppCompat.NoActionBar" ...

Make MainActivity extends FlutterFragmentActivity and initialize the Cast context:

CastContext.getSharedInstance(applicationContext)
Both

You can now add a ChromeCastButton widget to your widget tree.

The button can be controlled with the ChromeCastController that is passed to the ChromeCastButton's onButtonCreated callback.

import 'package:flutter/material.dart';
import 'package:flutter_video_cast/flutter_video_cast.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: CastSample(),
    );
  }
}


class CastSample extends StatefulWidget {
  @override
  _CastSampleState createState() => _CastSampleState();
}

class _CastSampleState extends State<CastSample> {
  ChromeCastController _controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Cast Sample'),
        actions: [
          ChromeCastButton(
            onButtonCreated: (controller) {
              setState(() => _controller = controller);
              _controller?.addSessionListener();
            },
            onSessionStarted: () {
              _controller?.loadMedia('https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4');
            },
          ),
        ],
      ),
    );
  }
}

See the example directory for a complete sample app.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。