cactbot
cactbot copied to clipboard
raidboss: Add option to play sound through ACT
Currently sound is played through the browser only, which doesn't work for ACT Discord Plugins. It'd be nice to have an option to be able to play sounds through ACT's APIs instead. This would need an event handler similar to tts.
This isn't too hard to do on the OverlayPlugin (or cactbot) side:
diff --git a/OverlayPlugin.Core/EventSources/MiniParseEventSource.cs b/OverlayPlugin.Core/EventSources/MiniParseEventSource.cs
index 316d9dc..6b5956a 100644
--- a/OverlayPlugin.Core/EventSources/MiniParseEventSource.cs
+++ b/OverlayPlugin.Core/EventSources/MiniParseEventSource.cs
@@ -170,6 +170,16 @@ namespace RainbowMage.OverlayPlugin.EventSources
return null;
});
+ RegisterEventHandler("sound", (msg) => {
+ var fileName = msg["file"]?.ToString();
+ if (fileName == null)
+ return null;
+
+ // TODO: fileName has to be an absolute path.
+ ActGlobals.oFormActMain.PlaySound(fileName);
+ return null;
+ });
+
foreach (var propName in DefaultCombatantFields)
{
CachedCombatantPropertyInfos.Add(propName,
However, there are a lot of open questions here. ACT plays sounds via absolute path on the file system. cactbot plays sounds via relative path from a url. cactbot can use both remote urls and file urls. It also seems to have more latency than playing through the browser in cactbot.
Event handlers at the moment don't have any notion of "what is my url". Even if they did, what would this mean for cactbot remote urls? Would this handler need to download a remote sound file and then play it? Would we want to cache those downloads somewhere?
There was a recent comment on Discord about this, so I thought I would share some details. ACT will pass the location string verbatim to the sound engine. Relative paths probably won't work because the relative context is unknown... is it ACT's working folder? The Windows Media Player API will accept URIs but other sound engines probably will not. I have no idea if WMP will cache sounds it plays from remote URIs.