mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (929333fe2)
This commit is contained in:
@@ -130,22 +130,18 @@ You can load a file without having to import it beforehand using the code snippe
|
||||
.. code-tab:: gdscript
|
||||
|
||||
func load_mp3(path):
|
||||
var file = File.new()
|
||||
file.open(path, File.READ)
|
||||
var file = FileAccess.open(path, FileAccess.READ)
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = file.get_buffer(file.get_length())
|
||||
file.close()
|
||||
return sound
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
public AudioStreamMP3 LoadMP3(string path)
|
||||
{
|
||||
var file = new File();
|
||||
file.Open(path, File.READ);
|
||||
using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);
|
||||
var sound = new AudioStreamMP3();
|
||||
sound.Data = file.GetBuffer(file.GetLength());
|
||||
file.Close();
|
||||
return sound;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user