Search packages, repositories and app categories

Package detailsv0.1.2

just_audio_cache

Collection of extension function of [just_audio](https://pub.dev/packages/just_audio) package for auto-handle caching audio files

AndroidiOSmacOS
30-day downloads
245
Likes
47
Pub points
130

Install package

flutter pub add just_audio_cache

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

just_audio_cache is a Flutter package that extends the just_audio library with automatic audio file caching capabilities. It simplifies offline playback by intelligently managing cached audio files, reducing redundant downloads and improving performance. The package integrates seamlessly with just_audio, offering extension methods to handle caching logic without requiring manual intervention. Ideal for apps that stream or play audio content frequently, it ensures efficient storage usage and faster load times on subsequent plays.

Use cases

  • Offline audio playback
  • Reducing data usage
  • Faster audio loading
  • Streaming app enhancements
  • Caching remote audio files
  • Improving user experience in low-connectivity areas

Key features

  • Automatic caching of audio files
  • Seamless integration with just_audio
  • Extension methods for easy use
  • Efficient storage management
  • Support for multiple platforms
  • Configurable cache size

Suitable for

  • Audio streaming apps
  • Podcast players
  • Music applications
  • Apps with frequent audio playback
  • Developers using just_audio
  • Projects prioritizing offline functionality

Considerations

  • Requires just_audio to be installed
  • Cache size must be managed manually
  • Limited customization for cache policies
  • Not suitable for very large audio libraries
  • May require additional permissions on some platforms
  • Dependent on platform-specific storage behavior

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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();

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package

No data available yet.