Skip to content

Class · inherits Instance

AudioPlayer

Official docs ↗

Used to play audio assets.

About AudioPlayer

AudioPlayer is used to play audio assets. It provides a single Output pin which can be connected to other pins via Wires.

Properties 13

  • Asset: ContentIdThe asset to be loaded into the AudioPlayer.

    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.

  • AudioContent: ContentHiddenThe audio content to be loaded into the AudioPlayer.

    The audio content 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.

  • AutoLoad: booleanControls whether Asset loads automatically once assigned.

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

  • AutoPlay: booleanDenotes whether this AudioPlayer starts playing as soon as it spawns in for the first time.

    Denotes whether this AudioPlayer starts playing as soon as it enters the DataModel for the first time. This only applies to AudioPlayers that are created or deserialized locally, and does not apply to AudioPlayers generated via replication. This property is primarily used at edit time in Studio to have an AudioPlayer begin when entering a play session.

  • IsPlaying: booleanDenotes whether this AudioPlayer is currently playing or planning to play.

    Denotes whether this AudioPlayer is currently playing or planning to play. This property is read-only, but replicates. To play and stop an AudioPlayer at runtime, use the Play() and Stop() methods.

  • IsReady: booleanReadOnlyNotReplicatedDenotes whether this AudioPlayer is loaded, buffered, and ready to play.

    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.

  • Looping: booleanControls whether this AudioPlayer loops.

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

  • LoopRegion: NumberRangeA range, in seconds, denoting a desired loop start and loop end within the PlaybackRegion of this AudioPlayer.

    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.

  • PlaybackRegion: NumberRangeRange in seconds denoting a desired start time (minimum) and stop time (maximum) within the TimeLength.

    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.

  • PlaybackSpeed: doubleControls how quickly the asset will be played, which controls its pitch.

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

  • TimeLength: doubleReadOnlyNotReplicatedDenotes the length of the loaded asset.

    Denotes the length of the loaded Asset in seconds.

  • TimePosition: doubleTracks the current position of the playhead within the asset.

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

  • Volume: floatControls how loudly the asset will be played.

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

Methods 7

  • Cancel(actionId: int64?) → booleanAttempts to cancel a pre-planned future Play or Stop command.

    Attempts to cancel a Play() or Stop() command that was scheduled to occur at a future time. When Play() or Stop() is called with an atTime argument, the action is scheduled against GetMixerTime() and the call returns a unique actionId. Passing that actionId to this method prevents the scheduled action from taking effect.

    Returns true if the pending action was found and successfully cancelled. Returns false if the action has already occurred, was never scheduled, or the supplied actionId does not correspond to a pending action.

  • GetConnectedWires(pin: string) → List<Wire>Returns an array of Wires that are connected to the specified pin.

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

  • GetInputPins() → ArrayGets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

    Gets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

    For AudioPlayer, there are none.

  • GetOutputPins() → ArrayGets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

    Gets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

    For AudioPlayer, this is Output only.

  • GetWaveformAsync(timeRange: NumberRange, samples: int) → ArrayYieldsReturns a sampling of the waveform data for the loaded Asset.

    Returns a sampling of the waveform data for the loaded Asset, allowing you to check the volume of an asset over its full duration without playing it. Unlike AudioAnalyzer, which measures volume levels of a live audio stream in real time, this method analyzes the asset ahead of time, making it suitable for waverform visualization or logic that needs audio content before playback begins.

  • Play(atTime: double?) → int64?Plays the AudioPlayer from wherever its TimePosition is.

    Plays the AudioPlayer from wherever its TimePosition is. Replicates from server to client. When atTime is provided, the action is scheduled against GetMixerTime() for sample-accurate, framerate-independent timing — useful for rhythm games or any scenario where audio changes must align precisely with a beat.

  • Stop(atTime: double?) → int64?Stops the AudioPlayer wherever its TimePosition is.

    Stops the AudioPlayer wherever its TimePosition is. Replicates from server to client. When atTime is provided, the action is scheduled against GetMixerTime() for sample-accurate, framerate-independent timing, enabling precise beat-synchronized stops or track transitions.

Events 3

  • EndedAudioPlayer.Ended:Connect(function())Fires when the AudioPlayer has completed playback and stopped.

    Fires after the AudioPlayer has completed playback and stopped. Note this event will not fire for audio with Looping 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.

  • LoopedAudioPlayer.Looped:Connect(function())Fires when the AudioPlayer loops.

    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.

  • WiringChangedAudioPlayer.WiringChanged:Connect(function(connected, pin, wire, instance))Fires when another instance is connected to or disconnected from the AudioPlayer via a Wire.

    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.

AudioPlayer also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.