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

audio_video_progress_bar 封面
插件详情v2.0.3

audio_video_progress_bar

一个进度条小部件,用于显示或更改音频或视频流的位置。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6.6万
喜欢数
446
Pub 分数
150

安装插件

flutter pub add audio_video_progress_bar

插件介绍

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

一个用于显示和控制音频或视频流播放位置的 Flutter 小部件。它提供了一个可交互的视觉进度条,可用于在媒体内容中快速定位。该小部件可自定义,并可在移动、网页和桌面等多个平台上运行。它与音频和视频播放器无缝集成,在播放过程中提供流畅的用户体验。

适合场景

  • 媒体播放器界面
  • 视频时间轴导航
  • 音频轨道定位
  • 交互式媒体控制
  • 流媒体应用界面
  • 实时音频/视频播放

主要特点

  • 可跳转进度条
  • 跨平台兼容性
  • 可自定义样式
  • 实时播放反馈
  • 同时支持音频和视频
  • 响应式触摸交互

适合对象

  • 开发媒体应用的开发者
  • 需要交互式进度指示器的UI设计师
  • 需要精确媒体控制的应用
  • 跨平台音视频应用
  • 教育或娱乐流媒体平台

使用建议

  • 需要与媒体播放器集成
  • 仅限播放位置控制
  • 可能需要额外的状态管理
  • 不适用于非媒体使用场景
  • 依赖外部媒体处理逻辑

原始 README

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

audio_video_progress_bar

A progress bar widget to show or change the position of an audio or video stream.

Note: This package does not play audio or video itself. It's just a widget you can use to show the progress of your audio or video player. This widget is easier to connect to a media player than the Flutter Slider widget is. It also supports showing the buffered status for streamed media.

Example

Add the ProgressBar widget to your UI. A static example would look like this:

ProgressBar(
  progress: Duration(milliseconds: 1000),
  buffered: Duration(milliseconds: 2000),
  total: Duration(milliseconds: 5000),
  onSeek: (duration) {
    print('User selected a new time: $duration');
  },
),

However, you would normally wrap it in a builder widget that is updated by an audio or video player. That might look something like this:

StreamBuilder<DurationState>(
  stream: _durationState,
  builder: (context, snapshot) {
    final durationState = snapshot.data;
    final progress = durationState?.progress ?? Duration.zero;
    final buffered = durationState?.buffered ?? Duration.zero;
    final total = durationState?.total ?? Duration.zero;
    return ProgressBar(
      progress: progress,
      buffered: buffered,
      total: total,
      onSeek: (duration) {
        _player.seek(duration);
      },
    );
  },
),

...

class DurationState {
  const DurationState({this.progress, this.buffered, this.total});
  final Duration progress;
  final Duration buffered;
  final Duration total;
}

You can check out the GitHub repo for the full example using the just_audio plugin. There is no requirement to use just_audio or even a StreamBuilder, though. You can use any audio or video player that provides updates about the current play location. Just rebuild the ProgressBar widget with the new Duration states.

You'll probably want to add other buttons like start and pause, but these are not included with this package. They aren't hard to build, though, and you can find an example in the GitHub repo.

Thanks to the just_audio code example for help with the buttons.

Customization

The default colors use the theme's primary color, so changing the theme will also update this widget:

However, you can set your own colors and sizes as well:

ProgressBar(
  progress: progress,
  buffered: buffered,
  total: total,
  progressBarColor: Colors.red,
  baseBarColor: Colors.white.withOpacity(0.24),
  bufferedBarColor: Colors.white.withOpacity(0.24),
  thumbColor: Colors.white,
  barHeight: 3.0,
  thumbRadius: 5.0,
  onSeek: (duration) {
    _player.seek(duration);
  },
);

Which would look like this (if the app has a dark theme):

You can also set the location of the time labels:

ProgressBar(
  ...
  timeLabelLocation: TimeLabelLocation.sides,
);

Now the time labels are displayed on the side:

Notes

If your interested in how this widget was made, check out the article Creating a Flutter widget from scratch.

Please open an issue if you find any bugs.

New feature requests

There are a number of interesting feature requests in the GitHub issues. Unfortunately, with the other projects I have going on, I generally don't get around to implementing very many of them. Your best bet is to copy the source code and implement the feature yourself. On the other hand, if the issue you is important enough to you or your company, I'm open to being hired to add your desired feature to this package or to create a custom solution.

所属分类

源码仓库

使用此插件的项目