AudioCache class

This class represents a cache for Local Assets to be played.

Flutter can only play audios on device folders, so first this class copies the files to a temporary folder, and then plays them. You can pre-cache your audio, or clear the cache, as desired.

Constructors

AudioCache({String prefix = "", AudioPlayer fixedPlayer, bool respectSilence = false})

Properties

fixedPlayer AudioPlayer
This is an instance of AudioPlayer that, if present, will always be used. [...]
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
loadedFiles Map<String, File>
A reference to the loaded files.
read / write
prefix String
This is the path inside your assets folder where your files lie. [...]
read / write
respectSilence bool
This flag should be set to true, if player is used for playing internal notifications [...]
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

clear(String fileName) → void
Clears the cache of the file fileName. [...]
clearCache() → void
Clears the whole cache.
disableLog() → void
Disables AudioPlayer logs (enable only if debugging, otherwise they can be quite overwhelming). [...]
fetchToMemory(String fileName) Future<File>
load(String fileName) Future<File>
Loads a single fileName to the cache. [...]
loadAll(List<String> fileNames) Future<List<File>>
Loads all the fileNames provided to the cache. [...]
loop(String fileName, {double volume = 1.0, bool isNotification, PlayerMode mode = PlayerMode.MEDIA_PLAYER, bool stayAwake}) Future<AudioPlayer>
Like play, but loops the audio (starts over once finished). [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
play(String fileName, {double volume = 1.0, bool isNotification, PlayerMode mode = PlayerMode.MEDIA_PLAYER, bool stayAwake}) Future<AudioPlayer>
Plays the given fileName. [...]
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited