Class AudioStreamMP3
- Namespace
- Godot
- Assembly
- GodotSharp.dll
MP3 audio stream driver. See Data if you want to load an MP3 file at run-time.
Note: This class can optionally support legacy MP1 and MP2 formats, provided that the engine is compiled with the minimp3_extra_formats=yes
SCons option. These extra formats are not enabled by default.
public class AudioStreamMP3 : AudioStream, IDisposable
- Inheritance
-
AudioStreamMP3
- Implements
- Inherited Members
Constructors
AudioStreamMP3()
public AudioStreamMP3()
Properties
BarBeats
public int BarBeats { get; set; }
Property Value
BeatCount
public int BeatCount { get; set; }
Property Value
Bpm
public double Bpm { get; set; }
Property Value
Data
Contains the audio data in bytes.
You can load a file without having to import it beforehand using the code snippet below. Keep in mind that this snippet loads the whole file into memory and may not be ideal for huge files (hundreds of megabytes or more).
public AudioStreamMP3 LoadMP3(string path)
{
using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
var sound = new AudioStreamMP3();
sound.Data = file.GetBuffer(file.GetLength());
return sound;
}
public byte[] Data { get; set; }
Property Value
- byte[]
Loop
If true, the stream will automatically loop when it reaches the end.
public bool Loop { get; set; }
Property Value
LoopOffset
Time in seconds at which the stream starts after being looped.
public double LoopOffset { get; set; }
Property Value
Methods
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
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
LoadFromBuffer(byte[])
Creates a new AudioStreamMP3 instance from the given buffer. The buffer must contain MP3 data.
public static AudioStreamMP3 LoadFromBuffer(byte[] streamData)
Parameters
streamData
byte[]
Returns
LoadFromBuffer(ReadOnlySpan<byte>)
Creates a new AudioStreamMP3 instance from the given buffer. The buffer must contain MP3 data.
public static AudioStreamMP3 LoadFromBuffer(ReadOnlySpan<byte> streamData)
Parameters
streamData
ReadOnlySpan<byte>
Returns
LoadFromFile(string)
Creates a new AudioStreamMP3 instance from the given file path. The file must be in MP3 format.
public static AudioStreamMP3 LoadFromFile(string path)
Parameters
path
string