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: 'Text_Volume', value: level}); xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'Slider_Volume', value: sliderVal}); }) function guiEvent(event) { if (event.WidgetId === 'Slider_Volume' && event.Type === 'released'){ console.log(event.WidgetId, event.Value) let volume_value = event.Value/255*100 volume_value = (Math.ceil(volume_value)) console.log('Slider output transformed to range of volume level and rounded up:', volume_value) xapi.Command.Audio.Volume.Set({Level:volume_value}) console.log('Set Volume to:', volume_value) xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'Text_Volume', value: volume_value}) } } xapi.Event.UserInterface.Extensions.Widget.Action.on(guiEvent);