Audio class Audio

Manages audio playback for sounds and music.

Constructors

Audio([AudioContext? context])

Properties

audioContext AudioContext
The Web Audio API AudioContext used for processing and playing sounds.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
musicDuration double
Gets the total duration of the currently loaded music in seconds. Returns 0.0 if no music is loaded or duration is not available.
no setter
musicPosition double
Gets the current playback position of the music in seconds. Returns 0.0 if no music is loaded.
no setter
musicProgress double
Gets the playback progress of the music, from 0.0 (start) to 1.0 (end). Returns 0.0 if duration is 0 or music is not loaded.
no setter
musicState ChannelState
The current playback state of the music. See ChannelState.
getter/setter pair
musicVolume double
Gets the current volume of the music, ranging from 0.0 (silent) to 1.0 (full volume).
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

initMusicVisualizer([int fftSize = 2048]) AudioVisualizer
Initializes or reconfigures the AudioVisualizer for the current music.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
obtainFreeChannel(List<int>? targetChannels) int
Finds and returns the ID of a free (stopped) audio channel.
pauseChannel(int channelId) → dynamic
Pauses the sound playing on the specified channelId.
pauseMusic() → void
Pauses the currently playing music.
playMusic(String path, bool loop, [double loopStart = -1, double loopEnd = -1, dynamic hz = 44100]) → void
Loads and plays music from the given path.
playSound(Sound sound, {int channel = -1, bool loop = false, double? loopStart, double? loopEnd}) int
Plays the given Sound.
playSoundOnTargetChannels(Sound sound, {List<int>? targetChannels, bool loop = false, double? loopStart, double? loopEnd}) int
Plays the given Sound on one of the specified target channels.
resume() → dynamic
Resumes all audio playback that was previously suspended.
resumeChannel(int channelId) → dynamic
Resumes a paused sound on the specified channelId.
resumeMusic() → void
Resumes playback of paused music.
setPan(int channelId, double pan) → void
Sets the stereo panning for the sound on the specified channelId.
setRate(int channelId, double rate) → void
Sets the playback rate for the sound on the specified channelId.
setVolume(int channelId, double volume) → void
Sets the volume for the sound on the specified channelId.
stopChannel(int channelId) → dynamic
Stops the sound playing on the specified channelId.
stopMusic() → void
Stops the currently playing or paused music.
suspend() → dynamic
Suspends all audio playback (music and sounds).
toString() String
A string representation of this object.
inherited

Operators

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

Constants

audioChannelCount → const int