diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-07-20 22:33:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 22:33:49 +0200 |
commit | fa2dcc7ace5fefd7038bde2e420b2e96235a43df (patch) | |
tree | dec155b8bf545c5cf0799974189ebf00c794e397 /modules/minimp3 | |
parent | 5db878a76e747dedc66ca8e6892098adb517f660 (diff) | |
parent | 8c7d4996c9cd610b313bcb2119d13ee11871bcfe (diff) |
Merge pull request #47935 from HaSa1002/doc-loading-run-time
Diffstat (limited to 'modules/minimp3')
-rw-r--r-- | modules/minimp3/doc_classes/AudioStreamMP3.xml | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/modules/minimp3/doc_classes/AudioStreamMP3.xml b/modules/minimp3/doc_classes/AudioStreamMP3.xml index f5f7d3ef17..404f6c31e5 100644 --- a/modules/minimp3/doc_classes/AudioStreamMP3.xml +++ b/modules/minimp3/doc_classes/AudioStreamMP3.xml @@ -4,13 +4,36 @@ MP3 audio stream driver. </brief_description> <description> - MP3 audio stream driver. + MP3 audio stream driver. See [member data] if you want to load an MP3 file at run-time. </description> <tutorials> </tutorials> <members> <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()"> 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). + [codeblocks] + [gdscript] + func load_mp3(path): + var file = File.new() + file.open(path, File.READ) + var sound = AudioStreamMP3.new() + sound.data = file.get_buffer(file.get_length()) + file.close() + return sound + [/gdscript] + [csharp] + public AudioStreamMP3 LoadMP3(string path) + { + var file = new File(); + file.Open(path, File.READ); + var sound = new AudioStreamMP3(); + sound.Data = file.GetBuffer(file.GetLength()); + file.Close(); + return sound; + } + [/csharp] + [/codeblocks] </member> <member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false"> If [code]true[/code], the stream will automatically loop when it reaches the end. |