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

插件详情v1.30.0

better_player

高级视频播放器。它解决了许多常见用例,且易于运行。

近 30 天下载
6420
喜欢数
1310
Pub 分数
160

安装插件

flutter pub add better_player

插件介绍

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

Better Player 是一个适用于 Flutter 的高级视频播放器,通过简单直观的 API 解决常见的视频播放问题。它支持多种流媒体协议、自适应码率流媒体,并提供可自定义的 UI 组件。设计简洁易用,使开发者能够快速在不同平台上实现强大的视频播放功能。该包文档齐全且持续维护,非常适合需要高质量视频体验的应用。

适合场景

  • 流媒体视频内容
  • 自适应码率播放
  • 自定义视频 UI
  • 离线视频播放
  • 实时视频流

主要特点

  • 支持多种视频格式
  • 内置控件和手势
  • 可扩展的部件系统
  • 低延迟播放
  • 与HLS和DASH的集成

适合对象

  • 视频密集型应用
  • 教育平台
  • 媒体流服务
  • 按需视频应用
  • 实时事件直播

使用建议

  • 需要额外设置才能使用高级功能
  • 有限的平台特定自定义
  • 依赖外部依赖项
  • 可能增加应用大小
  • 需要正确处理网络权限

原始 README

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

Better Player

pub package pub package pub package

Better Player handles the complex video playback edge cases so you don't have to. Originally based on video_player, it's now fully independent. It tackles HLS, DRM, and caching out of the box.

[IMPORTANT] Migrating from 0.0.84 to 1.x.x? See the Migration Guides section below.


📱 Visual Showcase

Default Controls Settings Menu Audio Tracks Event Listener

🏆 vs Competitors

Why choose Better Player? Here is how it stacks up against the alternatives.

Feature Better Player video_player chewie media_kit
Engine ExoPlayer/AVPlayer/Shaka ExoPlayer/AVPlayer video_player libmpv
UI Controls ✅ Built-in & Customizable ❌ None ✅ Built-in ✅ Built-in
HLS / DASH ✅ Native ⚠️ Basic ⚠️ Basic ✅ Native
DRM Support ✅ Widevine/FairPlay/ClearKey ❌ None ❌ None ❌ None
Subtitles ✅ Advanced (WebVTT, HTML, SRT) ⚠️ Basic (SRT only) ⚠️ Basic ✅ Advanced
Caching ✅ Built-in ❌ None ❌ None ❌ None
Playlists ✅ Built-in ❌ None ❌ None ✅ Built-in

🚀 Key Features

  • Adaptive Streaming: Play HLS, DASH, and Smooth Streaming with automatic track selection.
  • DRM Support: Protect your content with Widevine, FairPlay, and ClearKey.
  • Smart Caching: Cache videos for seamless offline playback.
  • Picture in Picture (PiP): Keep videos playing while users multitask.
  • Advanced Subtitles: Parse SRT and WebVTT, including HTML tags.

📦 Quick Start

1. Add dependency

Add Better Player to your pubspec.yaml:

dependencies:
  better_player: ^1.10.0
2. Basic Usage

Use the network factory to get a player up and running fast.

import 'package:better_player/better_player.dart';

// Inside your build method
AspectRatio(
  aspectRatio: 16 / 9,
  child: BetterPlayer.network(
    "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
    betterPlayerConfiguration: PlayerConfiguration(
      aspectRatio: 16 / 9,
      looping: true,
      autoPlay: true,
    ),
  ),
)
3. Advanced Controller Usage

Need full control? Initialize a BetterPlayerController manually.

BetterPlayerController _controller = BetterPlayerController(
    const PlayerConfiguration(),
    betterPlayerDataSource: PlayerDataSource(
        DataSourceType.network,
        "https://example.com/video.mp4",
    ),
);

BetterPlayer(controller: _controller)

🤖 AI Agent Quick Reference

Writing a script or prompt? Feed this to your AI to get the right code on the first try.

  • Initialization: Always initialize BetterPlayerController in initState() with a PlayerConfiguration and PlayerDataSource.
  • Core Classes:
    • BetterPlayerController: Manages state and configuration.
    • PlayerDataSource: Wraps video URL, DRM config, subtitles, headers.
    • PlayerConfiguration: UI, looping, autoPlay, aspect ratio.
    • PlayerControlsConfiguration: Colors, icons, padding for the control bar.
  • Subtitles: Pass PlayerSubtitlesSource directly into PlayerDataSource.
  • Disposal: Default is autoDispose: true. Avoid manual controller.dispose() unless you opt out.

🔄 Migration Guides

Moving from another package? Follow these guides:


📖 Resources


🤝 Contributing

Bugs? Feature requests? Open an issue. Better yet, submit a PR.

💼 Enterprise Support

Need a custom video source adapter, bespoke DRM implementation, or tailored UI controls? I'm available for consulting.

Let's talk on LinkedIn →

所属分类

依赖

依赖清单 17 项

源码仓库

使用此插件的项目