-
Notifications
You must be signed in to change notification settings - Fork 8
Audio
Starting with 0.5.2, the soundManager is no longer part of PML itself. Instead, it was moved to pmlapi, a separate mod.
If you are planning to use soundManger, be sure to add the pmlapi dependency to your mod's version.json(for 0.6.0 onward) or manifest.json(for 0.5.2):
"dependencies": [
{
"id": "pmlapi",
"version": "0.1.2"
}
]version 0.1.2 is the newest for 0.5.2.
Instead of pml.soundManager, you now call the pmlapi mod:
pml.getMod("pmlapi").soundManagerYou can also make a variable for pmlapi:
this.pApi = pml.getMod("pmlapi");this way you can use
this.pApi.soundManagerinstead of having to use pml.getMod every time
In order to play a sound, you have to register it first. This has to be done in postInit, not init.
To register a sound, use this.pApi.soundManager.registerSound like this:
this.pApi.soundManager.registerSound(name, [url]);name is the name of the sound
url is the url to the audio file, please make sure to not use relative links, as some devices do not support these
After havig registered the sound, it can be played from within your mod directly or in mixins using this.pApi.soundManager.playSound like this:
this.pApi.soundManager.playSound(name, volume);name is the name given to the sound
volume is the volume that the sound should be played at
You can override sounds:
thisYou can add audio to be played using PolyTrack's sound manager using PolyModLoader
In order to play a sound, you have to register it first. This has to be done in postInit, not init.
To register a sound, use pml.soundManager.registerSound like this:
pml.soundManager.registerSound(name, [url]);name is the name of the sound
url is the url to the audio file, please make sure to not use relative links, as some devices do not support these
After havig registered the Audio, it can be played from within your mod directly or in mixins using pml.soundManager.playSound like this:
pml.soundManager.playSound(name, volume);name is the name given to the sound
volume is the volume that the sound should be played at