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

插件详情v0.1.2

just_audio_cache

[just_audio](https://pub.dev/packages/just_audio) 包的扩展函数集合,用于自动处理音频文件缓存

AndroidiOSmacOS
近 30 天下载
245
喜欢数
47
Pub 分数
130

安装插件

flutter pub add just_audio_cache

插件介绍

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

just_audio_cache 是一个 Flutter 包,它扩展了 just_audio 库,提供了自动音频文件缓存功能。它通过智能管理已缓存的音频文件,简化了离线播放,减少了重复下载并提升了性能。该包与 just_audio 无缝集成,提供扩展方法来处理缓存逻辑,无需手动干预。适用于频繁流式传输或播放音频内容的应用程序,确保高效使用存储空间,并在后续播放时实现更快的加载速度。

适合场景

  • 离线音频播放
  • 减少数据使用
  • 更快的音频加载
  • 流媒体应用增强
  • 缓存远程音频文件
  • 在低连接性区域提升用户体验

主要特点

  • 自动缓存音频文件
  • 与 just_audio 的无缝集成
  • 用于便捷使用的扩展方法
  • 高效的存储管理
  • 对多个平台的支持
  • 可配置的缓存大小

适合对象

  • 音频流媒体应用
  • 播客播放器
  • 音乐应用
  • 频繁播放音频的应用
  • 使用 just_audio 的开发者
  • 优先考虑离线功能的项目

使用建议

  • 需要安装 just_audio
  • 缓存大小必须手动管理
  • 缓存策略的自定义功能有限
  • 不适用于非常大的音频库
  • 某些平台可能需要额外权限
  • 依赖于平台特定的存储行为

原始 README

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

just_audio_cache

pub package

Collection of extension function of just_audio package for auto-handle caching audio files

How to use

The premise is you already have just_audio package in your dependency

Core method dynamicSet would auto handle caching, if the target file not in cache, would download it and push in cache.

The next time the same url request call, would call the local file instead of requesting.

url is your audio source, a unique key that represents the stored file path,

pushIfNotExisted if true, when the file not exists, would download the file and push in cache

excludeCallback a callback function where you can specify which file you don't want to be cached

import 'package:just_audio_cache/just_audio_cache.dart';

void _play() async {
   // dynamic set your audio source
   await _player.dynamicSet(your_url);
   _player.play();
}

If you want to check if the target file exist in cache

_player.existedInLocal(your_url);

Manually add file to cache

_player.cacheFile(your_audio_url);

Get Cached file for the following url

_player.getCachedFile(url: your_url);

Clear all the cache from storage

_player.clear();

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目

暂无相关数据。