Class AudioStreamPlayer
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Plays an audio stream non-positionally.
To play audio positionally, use AudioStreamPlayer2D or AudioStreamPlayer3D instead of AudioStreamPlayer.
public class AudioStreamPlayer : Node, IDisposable
- Inheritance
-
AudioStreamPlayer
- Implements
- Inherited Members
Constructors
AudioStreamPlayer()
public AudioStreamPlayer()
Properties
Autoplay
If true
, audio plays when added to scene tree.
public bool Autoplay { get; set; }
Property Value
Bus
Bus on which this audio is playing.
Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master"
.
public StringName Bus { get; set; }
Property Value
MaxPolyphony
The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
public int MaxPolyphony { get; set; }
Property Value
MixTarget
If the audio configuration has more than two speakers, this sets the target channels. See AudioStreamPlayer.MixTargetEnum constants.
public AudioStreamPlayer.MixTargetEnum MixTarget { get; set; }
Property Value
PitchScale
The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
public float PitchScale { get; set; }
Property Value
Playing
If true
, audio is playing.
public bool Playing { get; set; }
Property Value
Stream
The AudioStream object to be played.
public AudioStream Stream { get; set; }
Property Value
StreamPaused
If true
, the playback is paused. You can resume it by setting StreamPaused to false
.
public bool StreamPaused { get; set; }
Property Value
VolumeDb
Volume of sound, in dB.
public float VolumeDb { get; set; }
Property Value
Methods
GetPlaybackPosition()
Returns the position in the AudioStream in seconds.
public float GetPlaybackPosition()
Returns
GetStreamPlayback()
Returns the AudioStreamPlayback object associated with this AudioStreamPlayer.
public AudioStreamPlayback GetStreamPlayback()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
HasStreamPlayback()
Returns whether the AudioStreamPlayer can return the AudioStreamPlayback object or not.
public bool HasStreamPlayback()
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
Play(float)
Plays the audio from the given fromPosition
, in seconds.
public void Play(float fromPosition = 0)
Parameters
fromPosition
float
Seek(float)
Sets the position from which audio will be played, in seconds.
public void Seek(float toPosition)
Parameters
toPosition
float
Stop()
Stops the audio.
public void Stop()
Events
Finished
Emitted when the audio stops playing.
public event Action Finished