Skip to content

Lua API: 8. Music

MCUmbrella edited this page Dec 4, 2023 · 1 revision

Music

Music can be automatically looped and cannot be converted to or from Sound. This class is like the combination of the Sound class and PlayingSound class.

NOTE: Only one music can be played at the same time.

Static functions

pause

Pause the playing music.

resume

Resume the paused music.

stop

Stop the music.

volume

Get or set the volume of the music.

Parameter:

  • Number vol (optional): The volume of the music, integer from 0 ~ 128.

Return: The new volume, or the current volume if the parameter "vol" is not present.

Member functions

getName

Get the friendly name of the music.

getPath

Get the path to the file used by the music.

play

Play the music from start and loop forever.

NOTE: This function doesn't return anything.

isCurrent

Check if the music is in use.

Return: true if so, false otherwise.

reassign

Assign another file to the music.

Parameter:

  • String newPath: The path to the new file.