AudioPlayer
Used to play audio assets.
Memory category | Internal |
---|
Member index 19
Description
AudioPlayer is used to play audio assets. It provides a single Output pin which can be connected to other pins via Wires.
History 37
- 652 Add WiringChanged
- 648 Add GetWaveformAsync
- 648 Change ReturnType of GetConnectedWires from Objects to Instances
- 645 Change ValueType of from Content to ContentId
- 643 Change Tags of AudioPlayer from [NotBrowsable] to []
- 637 Change ReturnType of GetConnectedWires from Array to Objects
- 629 Add Volume
- 618 Change Security of GetConnectedWires from PluginSecurity to None
- 616 Add Looped
- 616 Add Ended
- 616 Add
- 607 Change Security of GetConnectedWires from RobloxScriptSecurity to PluginSecurity
- 597 Change MemoryCategory of AudioPlayer from Instances to Internal
- 593 Add GetConnectedWires
- 592 Change Category of TimePosition from Data to Playback
- 592 Change Category of TimeLength from Data to Asset
- 592 Change Category of PlaybackSpeed from Data to Playback
- 592 Change Category of PlaybackRegion from Data to Regions
- 592 Change Category of Looping from Data to Playback
- 592 Change Category of LoopRegion from Data to Regions
- 592 Change Category of IsReady from Data to Asset
- 592 Change Category of IsPlaying from Data to Playback
- 592 Change Category of AutoLoad from Data to Asset
- 592 Change Category of AssetId from Data to Asset
- 588 Add Stop
- 588 Add Play
- 588 Add TimePosition
- 588 Add TimeLength
- 588 Add PlaybackSpeed
- 588 Add PlaybackRegion
- 588 Add Looping
- 588 Add LoopRegion
- 588 Add IsReady
- 588 Add IsPlaying
- 588 Add AutoLoad
- 588 Add AssetId
- 588 Add AudioPlayer
Members 19
AssetId
Type | Default | |
---|---|---|
string |
The asset to be loaded into the AudioPlayer. If AutoLoad is true, the asset loads immediately once this property is assigned. When loading is complete, IsReady becomes true.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | true |
AutoLoad
Type | Default | |
---|---|---|
bool | true |
Controls whether AssetId loads automatically once assigned. If false, the asset will load upon the first attempt to play.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | true |
Ended
Parameters (0) | ||
---|---|---|
No parameters. |
Fires after the AudioPlayer has completed playback and stopped.
Note this event will not fire for audio with
Looped set to true
since it continues playing
upon reaching its end. This event will also not fire when the audio is
stopped before playback has completed; for this, use
AudioPlayer:GetPropertyChangedSignal() on the
IsPlaying property.
This event is often used to destroy an AudioPlayer when it has completed playback.
Thread safety | Unsafe |
---|
GetConnectedWires
Parameters (1) | ||
---|---|---|
pin | string | |
Returns (1) | ||
Instances |
Returns an array of Wires that are connected to the specified pin. AudioPlayer has one "Output" pin.
Thread safety | Unsafe |
---|
History 5
- 648 Change ReturnType of GetConnectedWires from Objects to Instances
- 637 Change ReturnType of GetConnectedWires from Array to Objects
- 618 Change Security of GetConnectedWires from PluginSecurity to None
- 607 Change Security of GetConnectedWires from RobloxScriptSecurity to PluginSecurity
- 593 Add GetConnectedWires
GetWaveformAsync
Parameters (2) | ||
---|---|---|
timeRange | NumberRange | |
samples | int | |
Returns (1) | ||
Array |
Thread safety | Unsafe |
---|
History 1
- 648 Add GetWaveformAsync
IsPlaying
Type | Default | |
---|---|---|
bool | false |
Denotes whether this AudioPlayer is currently playing. This property is read-only, but replicates. To play and stop an AudioPlayer at runtime, use the Play() and Stop() methods.
Write security | RobloxSecurity |
---|---|
Thread safety | ReadSafe |
Category | Playback |
Loaded/Saved | false |
IsReady
Type | Default | |
---|---|---|
bool | false |
Denotes whether this AudioPlayer is loaded, buffered, and ready to play. Although uncommon, AudioPlayers may have their assets unloaded at runtime if there is extreme memory pressure, in which case IsReady will become false.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | false/true |
LoopRegion
Type | Default | |
---|---|---|
NumberRange | 0 60000 |
A range, in seconds, denoting a desired loop start and loop end within the PlaybackRegion of this AudioPlayer.
If the LoopRegion minimum is greater than the PlaybackRegion minimum, the loop starts from the LoopRegion minimum.
If the LoopRegion minimum is less than the PlaybackRegion minimum, the loop starts from the PlaybackRegion minimum.
If the LoopRegion maximum is greater than the PlaybackRegion maximum, the loop ends at the PlaybackRegion maximum.
If the LoopRegion maximum is less than the PlaybackRegion maximum, the loop ends at exactly the LoopRegion maximum.
If the LoopRegion minimum equals the LoopRegion maximum, the AudioPlayer uses the PlaybackRegion property instead.
Thread safety | ReadSafe |
---|---|
Category | Regions |
Loaded/Saved | true |
History 2
- 592 Change Category of LoopRegion from Data to Regions
- 588 Add LoopRegion
Looped
Parameters (0) | ||
---|---|---|
No parameters. |
Event that fires after the AudioPlayer loops. This happens when
the audio reaches the end of its content (or the end of the
LoopRegion if it is active) and
Looping is true
.
This event does not fire if the audio is looped manually by changing its TimePosition.
Thread safety | Unsafe |
---|
Looping
Type | Default | |
---|---|---|
bool | false |
Controls whether this AudioPlayer loops when exceeding the end of its TimeLength, LoopRegion, or PlaybackRegion.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
Play
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Plays the AudioPlayer from wherever its TimePosition is. Replicates from server to client.
Thread safety | Unsafe |
---|
PlaybackRegion
Type | Default | |
---|---|---|
NumberRange | 0 60000 |
Range in seconds denoting a desired start time (minimum) and stop time (maximum) within the TimeLength.
If the PlaybackRegion minimum is greater than 0, the sound begins playing from the PlaybackRegion minimum time.
If the PlaybackRegion minimum is less than 0, the sound begins playing from 0.
If the PlaybackRegion maximum is greater than the TimeLength, the sound stops at TimeLength.
If the PlaybackRegion maximum is less than the TimeLength, the sound stops at exactly the PlaybackRegion maximum.
If the PlaybackRegion minimum equals the PlaybackRegion maximum, the sound plays in its entirety.
Thread safety | ReadSafe |
---|---|
Category | Regions |
Loaded/Saved | true |
History 2
- 592 Change Category of PlaybackRegion from Data to Regions
- 588 Add PlaybackRegion
PlaybackSpeed
Type | Default | |
---|---|---|
double | 1 |
Multiplier controlling how quickly the asset will be played, directly controlling its perceived pitch. Ranges from 0 to 20.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
History 2
- 592 Change Category of PlaybackSpeed from Data to Playback
- 588 Add PlaybackSpeed
Stop
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Stops the AudioPlayer wherever its TimePosition is. Replicates from server to client.
Thread safety | Unsafe |
---|
TimeLength
Type | Default | |
---|---|---|
double | 0 |
Denotes the length of the loaded AssetId in seconds.
Thread safety | ReadSafe |
---|---|
Category | Asset |
Loaded/Saved | false/true |
History 2
- 592 Change Category of TimeLength from Data to Asset
- 588 Add TimeLength
TimePosition
Type | Default | |
---|---|---|
double | 0 |
Tracks and controls the current position of the playhead within the AssetId, in seconds.
Thread safety | ReadSafe |
---|---|
Category | Playback |
Loaded/Saved | true |
History 2
- 592 Change Category of TimePosition from Data to Playback
- 588 Add TimePosition
Volume
Type | Default | |
---|---|---|
float | 1 |
Volume level which is multiplied onto the output audio stream, controlling how loudly the asset will be played. Ranges from 0 to 3.
Thread safety | ReadSafe |
---|---|
Category | State |
Loaded/Saved | true |
WiringChanged
Parameters (4) | |
---|---|
connected | bool |
pin | string |
wire | Wire |
instance | Instance |
Thread safety | Unsafe |
---|
History 1
- 652 Add WiringChanged