搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.3

flutter_video_cast

flutter_video_cast 讓您發現 Chromecast 和 Apple TV 等投屏裝置並連接至它們。

近 30 天下載
35
喜歡數
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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。