Path: blob/master/modules/minimp3/doc_classes/AudioStreamMP3.xml
10278 views
<?xml version="1.0" encoding="UTF-8" ?>1<class name="AudioStreamMP3" inherits="AudioStream" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">2<brief_description>3MP3 audio stream driver.4</brief_description>5<description>6MP3 audio stream driver. See [member data] if you want to load an MP3 file at run-time.7[b]Note:[/b] This class can optionally support legacy MP1 and MP2 formats, provided that the engine is compiled with the [code]minimp3_extra_formats=yes[/code] SCons option. These extra formats are not enabled by default.8</description>9<tutorials>10</tutorials>11<methods>12<method name="load_from_buffer" qualifiers="static">13<return type="AudioStreamMP3" />14<param index="0" name="stream_data" type="PackedByteArray" />15<description>16Creates a new [AudioStreamMP3] instance from the given buffer. The buffer must contain MP3 data.17</description>18</method>19<method name="load_from_file" qualifiers="static">20<return type="AudioStreamMP3" />21<param index="0" name="path" type="String" />22<description>23Creates a new [AudioStreamMP3] instance from the given file path. The file must be in MP3 format.24</description>25</method>26</methods>27<members>28<member name="bar_beats" type="int" setter="set_bar_beats" getter="get_bar_beats" default="4">29</member>30<member name="beat_count" type="int" setter="set_beat_count" getter="get_beat_count" default="0">31</member>32<member name="bpm" type="float" setter="set_bpm" getter="get_bpm" default="0.0">33</member>34<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">35Contains the audio data in bytes.36You 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).37[codeblocks]38[gdscript]39func load_mp3(path):40var file = FileAccess.open(path, FileAccess.READ)41var sound = AudioStreamMP3.new()42sound.data = file.get_buffer(file.get_length())43return sound44[/gdscript]45[csharp]46public AudioStreamMP3 LoadMP3(string path)47{48using var file = FileAccess.Open(path, FileAccess.ModeFlags.Read);49var sound = new AudioStreamMP3();50sound.Data = file.GetBuffer(file.GetLength());51return sound;52}53[/csharp]54[/codeblocks]55</member>56<member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false">57If [code]true[/code], the stream will automatically loop when it reaches the end.58</member>59<member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset" default="0.0">60Time in seconds at which the stream starts after being looped.61</member>62</members>63</class>646566