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

插件详情v1.2.0

flutter_cast_video

flutter_cast_video 让您发现 Chrome Cast 和 Apple TV 等投射设备并连接到它们。

AndroidiOS
近 30 天下载
213
喜欢数
35
Pub 分数
140

安装插件

flutter pub add flutter_cast_video

插件介绍

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

flutter_cast_video 是一个 Flutter 包,可实现对 Chromecast 和 Apple TV 等投屏设备的发现和连接。它允许用户将移动应用中的媒体内容流式传输到兼容的显示设备上,从而在大屏幕上提升观看体验。该包支持 Android 和 iOS 平台,为希望为其应用程序添加投屏功能的开发者提供无缝集成。通过 pub add 进行最少配置,即可简化设备检测和流媒体工作流程。

适合场景

  • 将视频流传输到智能电视
  • 在 Apple TV 上启用远程播放
  • 将铸造集成到媒体应用中
  • 支持多设备投射
  • 允许实时内容镜像
  • 促进家庭娱乐应用

主要特点

  • Chromecast 和 Apple TV 的设备发现
  • 跨平台支持(Android 和 iOS)
  • 与 pub add 的简单集成
  • 实时投射功能
  • 内置连接管理
  • 安全流媒体协议

适合对象

  • 媒体和视频流应用
  • 智能家居娱乐系统
  • 教育类或演示类应用
  • 面向大屏幕观看的应用程序
  • 开发人员快速添加投射功能

使用建议

  • 需要兼容的投屏设备
  • 网络连接必不可少
  • 仅限支持的平台
  • 可能需要额外权限
  • 依赖于设备可用性
  • 用户必须手动选择目标设备

原始 README

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

flutter_cast_video

This is a clone and enhanced version from fluter_video_cast

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

Installation

First, add flutter_cast_video 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_cast_video/flutter_cast_video.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 项

源码仓库

使用此插件的项目

暂无相关数据。