Skip to content

Widget.assets

Your files from the Studio library: those in assets of manifest.json are used by name, and those in the image, video and audio menu fields with Widget.parameters.asset. Each one is loaded once and reused. If one is missing (it was deleted), it comes out empty and the alert goes on without it.

  • url(name): the URL of a file in assets, for a src or a background; "" if it is not declared.
  • image(source): a copy of the already loaded <img>, ready for append; null if there is no file or it could not load.
  • play(source, { volume }): plays a sound (volume from 0 to 1) and finishes when it ends; with no file, it finishes at once.
  • stop(source?): stops a playing sound (or all of them, without source); its play finishes at once.
  • video(source): the widget’s only <video> with that WebM loaded, for append and play(); null if there is no file.
await Widget.assets.play("bell.mp3", { volume: 0.6 });
const logo = await Widget.assets.image("logo.png");
if (logo) app.append(logo);