Widget.parameters
Widget.parameters reads the parameters: they are the values the viewer changes in the widget menu (you declare them in menu of
manifest.json). They are read with the method that matches their type, with a default value when there
is none:
string(name, fallback?): text.bool(name, fallback?):truefor"true"or"1";falsefor"false"or"0".int(name, fallback?): integer.number(name, fallback?): number with decimals.color(name, fallback?): color#RGB,#RRGGBBor#RRGGBBAA; if invalid, the default.font(name, fallback?): a value forfont-family; if it is a Google Font and is in the menu options, it loads it.asset(name): the URL of the file chosen in animage,videooraudiofield;""with “No file”.
Where the value comes from
Section titled “Where the value comes from”In this order: the URL first, then what was saved with the OBS URL in “Configure”, and finally the menu default. That is why changing a parameter in “Configure” does not force you to paste another URL in OBS.
const size = Widget.parameters.int("fontSize", 24);const color = Widget.parameters.color("textColor", "#ffffff");document.body.style.fontSize = `${size}px`;document.body.style.color = color;A file chosen in the menu is passed as is to Widget.assets:
Widget.assets.play(Widget.parameters.asset("followSound"));