AudioPlayer
AudioPlayer is used to play audio assets. It provides a single Output pin which can be connected to other pins via Wires.
Code Samples
local audioPlayer: AudioPlayer = Instance.new("AudioPlayer")
audioPlayer.Parent = workspace
audioPlayer.AssetId = "rbxassetid://9112854440"
local deviceOutput = Instance.new("AudioDeviceOutput")
deviceOutput.Parent = workspace
local wire = Instance.new("Wire")
wire.Parent = workspace
wire.SourceInstance = audioPlayer
wire.TargetInstance = deviceOutput
audioPlayer:Play()
Summary
Properties
The asset to be loaded into the AudioPlayer.
Controls whether Asset loads automatically once assigned.
Denotes whether this AudioPlayer is currently playing.
Denotes whether this AudioPlayer is loaded, buffered, and ready to play.
A range, in seconds, denoting a desired loop start and loop end within the PlaybackRegion of this AudioPlayer.
Controls whether this AudioPlayer loops.
Range in seconds denoting a desired start time (minimum) and stop time (maximum) within the TimeLength.
Controls how quickly the asset will be played, which controls its pitch.
Denotes the length of the loaded asset.
Tracks the current position of the playhead within the asset.
Controls how loudly the asset will be played.
Methods
Returns an array of Wires that are connected to the specified pin.
Plays the AudioPlayer from wherever its TimePosition is.
Stops the AudioPlayer wherever its TimePosition is.
Events
Fires when the AudioPlayer has completed playback and stopped.
Fires when the AudioPlayer loops.
Fires when another instance is connected to or disconnected from the AudioPlayer via a Wire.