Skip to content

sound.CreateMusicFromFile

Jérôme Leclercq edited this page Dec 8, 2020 · 2 revisions

API: sound.CreateMusicFromFile

Description:

Opens a music from a file path.

Prototype:

sound.CreateMusicFromFile(filePath: string) -> music: Music | nil, err: string

Parameters:

  1. filepath: Path to the image file (relative to the resources directory).

Returns:

  1. music: Music object opened from the file path or nil if the opening failed.
  2. err: If music is nil, an error message containing the reason this function failed.

Remarks:

  1. This function will fail if the image file has not been registered server-side using RegisterClientAssets, independently from the file existence on the host filesystem.
  2. Contrary to functions like assets.GetTexture, this function will always instantiate a new Music every call, even if another one already exists.
  3. Only the following extensions are supported:
    • aiff
    • au
    • avr
    • caf
    • flac
    • htk
    • ircam
    • mat4
    • mat5
    • mpc2k
    • nist
    • ogg
    • pvf
    • raw
    • rf64
    • sd2
    • sds
    • svx
    • voc
    • w64
    • wav
    • wve

Clone this wiki locally