Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarVoiceLuaBindings.cpp
blob: e3271fdb04f822f59672da79933523c092868bb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "StarVoiceLuaBindings.hpp"
#include "StarVoice.hpp"

namespace Star {

LuaCallbacks LuaBindings::makeVoiceCallbacks(Voice* voice) {
  LuaCallbacks callbacks;

  callbacks.registerCallback("speakers", [voice](Maybe<bool> onlyPlaying) -> List<Json> {
    List<Json> list;

    for (auto& speaker : voice->speakers(onlyPlaying.value(true))) {
      list.append(JsonObject{
        {"speakerId", speaker->speakerId },
        {"entityId",  speaker->entityId },
        {"name",      speaker->name },
        {"playing",   (bool)speaker->playing },
        {"muted",     (bool)speaker->muted },
        {"loudness",  (float)speaker->decibelLevel },
      });
    }

    return list;
  });

  return callbacks;
}

}