Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Musiclayer Wiki › Guides › Use MusicLayer as a Mod Developer

Use MusicLayer as a Mod Developer

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.