Reference API Roblox

Engine API

Website

Related

Reference API Roblox

AudioPlayer

Used to play audio assets.

Member index 19

HistoryMember
592AssetId: string
592AutoLoad: bool
592IsPlaying: bool
592IsReady: bool
592LoopRegion: NumberRange
592Looping: bool
592PlaybackRegion: NumberRange
592PlaybackSpeed: double
592TimeLength: double
592TimePosition: double
629Volume: float
648GetConnectedWires(pin: string): Instances
648GetWaveformAsync(timeRange: NumberRange, samples: int): Array
588Play(): null
588Stop(): null
616Ended()
616Looped()
652WiringChanged(connected: bool, pin: string, wire: Wire, instance: Instance)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

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

Members 19

AssetId

TypeDefault
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.

History 2

AutoLoad

TypeDefault
booltrue

Controls whether AssetId loads automatically once assigned. If false, the asset will load upon the first attempt to play.

History 2

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.

History 1

GetConnectedWires

Parameters (1)
pinstring
Returns (1)
Instances

Returns an array of Wires that are connected to the specified pin. AudioPlayer has one "Output" pin.

History 5

GetWaveformAsync

Parameters (2)
timeRangeNumberRange
samplesint
Returns (1)
Array
This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

IsPlaying

TypeDefault
boolfalse

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.

History 2

IsReady

TypeDefault
boolfalse

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.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 2

Tags: [ReadOnly, NotReplicated]

LoopRegion

TypeDefault
NumberRange0 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.

History 2

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.

History 1

Looping

TypeDefault
boolfalse

Controls whether this AudioPlayer loops when exceeding the end of its TimeLength, LoopRegion, or PlaybackRegion.

History 2

Play

Parameters (0)
No parameters.
Returns (1)
null

Plays the AudioPlayer from wherever its TimePosition is. Replicates from server to client.

History 1

PlaybackRegion

TypeDefault
NumberRange0 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.

History 2

PlaybackSpeed

TypeDefault
double1

Multiplier controlling how quickly the asset will be played, directly controlling its perceived pitch. Ranges from 0 to 20.

History 2

Stop

Parameters (0)
No parameters.
Returns (1)
null

Stops the AudioPlayer wherever its TimePosition is. Replicates from server to client.

History 1

TimeLength

TypeDefault
double0

Denotes the length of the loaded AssetId in seconds.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 2

Tags: [ReadOnly, NotReplicated]

TimePosition

TypeDefault
double0

Tracks and controls the current position of the playhead within the AssetId, in seconds.

History 2

Volume

TypeDefault
float1

Volume level which is multiplied onto the output audio stream, controlling how loudly the asset will be played. Ranges from 0 to 3.

History 1

WiringChanged

Parameters (4)
connectedbool
pinstring
wireWire
instanceInstance

Event that fires after a Wire becomes connected or disconnected, and that Wire is now or was previously connected to a pin on the AudioPlayer and to some other wirable instance.

History 1

Settings