Download the plugin from the latest release and install it on your server.
Add following lines to your .csproj file:
<PackageReference Include="SwiftlyS2.Plugin.Audio.API" Version="2.0.0" />You can find the configuration file in addons/swiftlys2/configs/plugins/Audio/config.jsonc after the plugin has properly started up once.
The configuration keys are as follows.
Control the complexity of opus encoder, ranging from 0 to 10 ( 10 by default ).
The higher the complexity is, the better the encoding quality but the slower the encoding speed.
You can try to lower this if you experience audio lag.
Whether to use ffmpeg as the pcm decoder, set to false by default.
Only enable this if you have correct ffmpeg executable installed and it exists in PATH.
Otherwise the native rust pcm decoder will be used.
public override void UseSharedInterface(IInterfaceManager interfaceManager)
{
// get api, you can store it in other place, but remember to reset it every time this method is called
IAudioApi api = interfaceManager.GetSharedInterface<IAudioApi>("audio");
// get a channel for your plugin
IAudioChannelController controller = api.UseChannel("test");
/// decode source from mp3 file
IAudioSource source = api.DecodeFromFile("E:/p.mp3");
// assign source to the channel
controller.SetSource(source);
// adjust volume
controller.SetVolumeToAll(0.5f);
// play
controller.PlayToAll();
}To see more api, please check AudioApi