AudioStorage class
Persistent Audio Memory Service
A singleton service responsible for storing and retrieving audio-related settings, including background music playlists, playback index, and volume levels for BGM, SFX, and Voice Acting.
This class implements both BgmStorage and VolumeStorage interfaces to ensure clean separation of responsibilities and allow other components to work with specific subsets of storage data.
Core Responsibilities:
- Persist BGM playlist and playback index between sessions
- Store and retrieve individual volume levels for each audio channel
- Provide a unified access point for all audio-related memory interactions
Initialization: Ensure that initialize is called before using this class. Usually done early during app startup.
Example Usage:
await AudioStorage.instance.initialize();
final playlist = AudioStorage.instance.getPlaylist();
final volume = AudioStorage.instance.bgmVolume;
Part of the Fifty Audio Engine package.
- Implemented types
Properties
- bgmPlayingIndex → int
-
Returns the current index or 0 if not found
no setter
-
bgmPlaylist
→ List<
String> -
Returns the BGM playlist or empty list if not found
no setter
- bgmVolume ↔ double
-
BGM volume (range: 0.0 - 1.0), defaults to 1.0
getter/setter pairoverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBgmActive ↔ bool
-
getter/setter pairoverride
- isSfxActive ↔ bool
-
getter/setter pairoverride
- isShuffle ↔ bool
-
Returns the shuffle state
getter/setter pair
- isVoiceActive ↔ bool
-
getter/setter pairoverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sfxVolume ↔ double
-
SFX volume (range: 0.0 - 1.0), defaults to 1.0
getter/setter pairoverride
- voiceVolume ↔ double
-
Voice Acting volume (range: 0.0 - 1.0), defaults to 1.0
getter/setter pairoverride
Methods
-
clear(
) → void -
Clears the stored playlist and index (e.g., for reset or logout)
override
-
getIndex(
) → int? -
Returns the current BGM playback index, or null if not set
override
-
getPlaylist(
) → List< String> ? -
Returns the saved playlist from storage, or null if not set
override
-
initialize(
) → Future< void> - Initialize the GetStorage box (must be called before use)
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resetAllAudioSettings(
) → void - Reset All Audio Settings
-
save(
List< String> playlist, int index) → void -
Saves the current BGM playlist and playback index to storage
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → AudioStorage
-
Public getter to access the instance
no setter