Beginner Help with Macro
I'm new to writing JavaScript macros for codecs so I really don't know what I'm doing. I've created a UI Extension with a toggle switch (on/off) named "classroom_toggle". I want to create a macro that will read the status of that switch toggle, and then flip the room between classroom and standard modes. I also want it to enable Presenter Track in classroom mode, and disable it in standard mode.
I've been referencing the rooms.cisco.com xapi docs, and asking chatgpt for some help. I'm probably way off the mark, but hoping someone in this community can give me some advice. My code looks like this (I'm 100% aware it's probably terrible in lots of ways, ha!):
import xapi from 'xapi';
function handleSwitchChange(event) { if (event.Type === 'Changed') { if (event.WidgetId === 'classroom_toggle') {
var switchState = event.Value; if (switchState === 'on') { console.log('Switch is ON'); xapi.Command.Provisioning.RoomType.Activate({ 'Name': 'Classroom' }); xapi.Command.Cameras.Presentertrack.Set({ 'Mode': 'Follow' }); } else if (switchState === 'off') { console.log('Switch is OFF'); xapi.Command.Provisioning.RoomType.Activate({ 'Name': 'Standard' }); xapi.Command.Cameras.Presentertrack.Set({ 'Mode': 'Off' }); } } } }
xapi.Event.UserInterface.Extensions.Widget.Action.on(handleSwitchChange);