import xapi from 'xapi'; xapi.Status.Audio.Volume.get().then((level) => { console.log("Setting text and slider to", level) let sliderVal = level/100*255 sliderVal = (Math.ceil(sliderVal)) xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'VolumeText', value: level}); xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'VolumeSlider', value: sliderVal}); }) function guiEvent(event) { if (event.WidgetId === 'VolumeSlider' && event.Type === 'released'){ console.log(event.WidgetId, event.Value) let Volume = event.Value/255*100 Volume = (Math.ceil(Volume)) console.log('Slider output transformed to range of microphone level and rounded up:', Volume) xapi.Command.Audio.Volume.Set({Device: "Internal", Level: Volume}) xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'VolumeText', value: Volume}) } } xapi.Event.UserInterface.Extensions.Widget.Action.on(guiEvent);