Constructor
new AudioItem(urlopt, configopt)
Creates an instance of AudioItem.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url |
string | null |
<optional> |
null | The URL of the audio file to load. |
config |
Object |
<optional> |
{} | Configuration for the audio item. |
- Source:
Classes
Members
currentTime
Gets the current playback position in seconds.
- Source:
duration
Gets the audio duration in seconds.
- Source:
loop
Gets the loop property.
- Source:
pitch
Gets the pitch value.
- Source:
seek
Gets the seek position in seconds.
- Source:
Methods
connect(audioMixer)
Connects the current instance to the provided audio mixer.
If already connected to a different audio mixer, it will first disconnect from the current one.
Parameters:
| Name | Type | Description |
|---|---|---|
audioMixer |
Object | The audio mixer to connect to. |
- Source:
disconnect()
Disconnects the current instance from the audio mixer.
If an audio mixer is connected, it stops the audio and disconnects the instance from the mixer.
- Source:
(async) load(url) → {Promise.<void>}
Asynchronously loads audio data from the provided URL.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The URL of the audio resource to load. |
- Source:
Returns:
A promise that resolves when the audio data is loaded.
- Type
- Promise.<void>
pause()
Pauses the audio playback and stores the current seek position.
- Source:
play(fromopt)
Starts playing the audio from the current seek position or a specified time.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
from |
number |
<optional> |
this.seek | The time in seconds from which to start playing the audio. |
- Source:
stop()
Stops the audio playback and resets the seek position.
- Source:
unload()
Unloads the current instance by disconnecting and clearing the buffer.
- Source: