Wiki 9Minecraft Wiki 9Minecraft

Use MusicLayer as a Mod Developer

Java EditionModGuides 4FAQ 10Related mods 48
DownloadMusicLayer Mod

Get the files on 9Minecraft

Contents (4)
  1. Accessing the Audio API
  2. Loading Music Sources
  3. Preventing Game Lag
  4. File Format Requirements

Accessing the Audio API

MusicLayer provides an input stream interface that other mods can use to trigger custom music. As a developer, you can:

  • Call MusicLayer's audio playback functions from your mod
  • Pass audio streams directly without managing file I/O yourself
  • Avoid game freezes by letting MusicLayer handle background streaming

Loading Music Sources

You can provide music through three methods:

1. Resource files: Pack .ogg files in your mod's resource folder and reference them by path

2. Web URLs: Provide direct links to hosted audio files

3. Input streams: Pass raw audio data directly to MusicLayer

Preventing Game Lag

MusicLayer handles all audio streaming asynchronously, so your mod code won't block the game thread. This means you can trigger music during intensive operations without causing stuttering.

File Format Requirements

Always use Ogg Vorbis (.ogg) format for compatibility. MusicLayer is optimized for this format and won't process other audio types reliably.

More guides for this mod