搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。