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

flutter_vlc_player 封面
套件詳情v7.4.4

flutter_vlc_player

一個基於 VLC 的 Flutter video_player 替代方案。支援在同一螢幕上使用多個播放器。

AndroidiOS
近 30 天下載
8440
喜歡數
548
Pub 分數
140

安裝套件

flutter pub add flutter_vlc_player

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter VLC Player 是基於 VLC 媒體播放器引擎建構的影片播放解決方案,相比 Flutter 的原生 video_player,提供了更高的相容性與效能。它支援在同一畫面上使用多個影片播放器,非常適合複雜的影片佈局。專為 Android 與 iOS 設計,利用 VLC 強大的解碼能力,可處理多種格式與串流協定。此套件為需要在 Flutter 應用中實現進階影片功能的開發者提供了一個可靠的替代方案。

適用情境

  • 播放不支援的編解碼器的影片
  • 同時顯示多個影片
  • 從 RTSP 或 HLS 源串流
  • 建構影片豐富的儀表板
  • 建立影片編輯預覽

主要特色

  • VLC 引擎整合
  • 多個玩家實例
  • 支援 RTSP、HLS 和 DASH
  • 硬體加速
  • 可自訂控件
  • 跨平台(Android 與 iOS)

適合對象

  • 媒體密集型應用
  • 即時視頻監控
  • 視訊會議介面
  • 帶有多媒體內容的教育平台
  • 需要廣泛格式支援的應用程式

使用建議

  • 由於 VLC 庫導致應用體積更大
  • 大量玩家可能導致的記憶體使用
  • 某些功能需要平台特定的設定
  • 與主流套件相比,文件較少
  • 可能需要額外的權限才能存取網路串流

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter VLC Player Plugin

Join the chat at https://discord.gg/mNY4fjVk Support me on Patreon flutter_vlc_player

A VLC-powered alternative to Flutter's video_player that supports iOS and Android.


Installation

iOS

If you're unable to view media loaded from an external source, you should also add the following:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

For more information, or for more granular control over your App Transport Security (ATS) restrictions, you should read Apple's documentation.

Make sure that following line in <project root>/ios/Podfile uncommented:

platform :ios, '9.0'

NOTE: While the Flutter video_player is not functional on iOS Simulators, this package (flutter_vlc_player) is fully functional on iOS simulators.

To enable vlc cast functionality for external displays (chromecast), you should also add the following:

<key>NSLocalNetworkUsageDescription</key>
<string>Used to search for chromecast devices</string>
<key>NSBonjourServices</key>
<array>
  <string>_googlecast._tcp</string>
</array>

Android

To load media/subitle from an internet source, your app will need the INTERNET permission.
This is done by ensuring your <project root>/android/app/src/main/AndroidManifest.xml file contains a uses-permission declaration for android.permission.INTERNET:

<uses-permission android:name="android.permission.INTERNET" />

As Flutter includes this permission by default, the permission is likely already declared in the file.

Note that if you got "Cleartext HTTP traffic to * is not permitted" you need to add the android:usesClearTextTraffic="true" flag in the AndroidManifest.xml file, or define a new "Network Security Configuration" file. For more information, check https://developer.android.com/training/articles/security-config


In order to load media/subtitle from internal device storage, you should put the storage permissions as follows:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

In some cases you also need to add the android:requestLegacyExternalStorage="true" flag to the Application tag in AndroidManifest.xml file to avoid acess denied errors. Android 10 apps can't acess storage without that flag. reference

After that you can access the media/subtitle file by

"/storage/emulated/0/{FilePath}"
"/sdcard/{FilePath}"

Android build configuration
  1. In android/app/build.gradle:
android {
    packagingOptions {
       // Fixes duplicate libraries build issue, 
       // when your project uses more than one plugin that depend on C++ libs.
        pickFirst 'lib/**/libc++_shared.so'
    }
   
   buildTypes {
      release {
         minifyEnabled true
         proguardFiles getDefaultProguardFile(
                 'proguard-android-optimize.txt'),
                 'proguard-rules.pro'
      }
   }
}
  1. Create android/app/proguard-rules.pro, add the following lines:
-keep class org.videolan.libvlc.** { *; }

Quick Start

To start using the plugin, copy this code or follow the example project in 'flutter_vlc_player/example'

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  VlcPlayerController _videoPlayerController;

  @override
  void initState() {
    super.initState();

    _videoPlayerController = VlcPlayerController.network(
      'https://media.w3.org/2010/05/sintel/trailer.mp4',
      hwAcc: HwAcc.full,
      autoPlay: false,
      options: VlcPlayerOptions(),
    );
  }

  @override
  void dispose() async {
    super.dispose();
    await _videoPlayerController.stopRendererScanning();
    await _videoPlayerController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: VlcPlayer(
          controller: _videoPlayerController,
          aspectRatio: 16 / 9,
          placeholder: Center(child: CircularProgressIndicator()),
        ),
      ),
    );
  }
}

Recording feature

To start/stop video recording, you have to call the startRecording(String saveDirectory) and stopRecording() methods, respectively. By calling the stop method you can get the path of recorded file from vlcPlayerController.value.recordPath.


Upgrade instructions

Version 5.0 Upgrade For Existing Apps

To upgrade to version 5.0 first you need to migrate the existing project to swift.

  1. Clean the repo:

    git clean -xdf

  2. Delete existing ios folder from root of flutter project. If you have some custom changes made to the iOS app - rename it or copy somewhere outside the project.

  3. Re-create the iOS app: This command will create only ios directory with swift support. See https://stackoverflow.com/questions/52244346/how-to-enable-swift-support-for-existing-project-in-flutter

    flutter create -i swift .

  4. Make sure to update the project according to warnings shown by the flutter tools. (Update Info.plist, Podfile).

If you have some changes made to the iOS app, recreate the app using above method and copy in the changed files.

Be sure to follow instructions above after


Breaking Changes (from V4 to V5)

Entire platform has been refactored in v5. It will require a refactor of your app to follow v5.


Known Issues

1) The video recording feature is problematic in iOS/Android: if the video reaches its end while you're recording it, the underlying vlckit/libvlc library fails to finalize the recording process, and we cannot retrieve the recorded file. The issue is reported and tracked here:
https://code.videolan.org/videolan/VLCKit/-/issues/394 (see last comment from September 22, 2020)


Current issues

Current issues list is here.
Found a bug? Open the issue.

所屬分類

依賴

依賴清單 2 項

  • flutter_vlc_player_platform_interface^2.0.5
  • meta^1.8.0

原始碼儲存庫

使用此套件的專案