Build

Your code here builds on the foundation listed below, and will be injected into a <div id="container"> element in the body.

Foundation

Diffuse comes with a foundation that preconfigures a lot of elements so you don't have to set them up yourself, along with a combination of elements for certain features. It internally tracks the DOM addition of the custom elements, so no need to worry about setting up an element multiple times. It also provides signals which can be used to track element creations. An example of this can be found in the "scrobbles" feature.

That said, you are not required not use this! You can, for example, setup a Diffuse audio engine element yourself that's in a different group so that it doesn't communicate with the default one; in case you want to make a dj-deck, or something like that, which would have multiple audio items playing at the same time. This does mean you will need to pay attention to more things, such as, how does this interact with other features the user has enabled.

Refer to the elements index to find out what each element does.

import foundation from "common/foundation.js" await foundation.configurator.artwork() await foundation.configurator.input() await foundation.configurator.metadata() await foundation.configurator.scrobbles() await foundation.engine.audio() await foundation.engine.queue() await foundation.engine.repeatShuffle() await foundation.engine.scope() await foundation.orchestrator.autoQueue() await foundation.orchestrator.favourites() await foundation.orchestrator.mediaSession() await foundation.orchestrator.output() await foundation.orchestrator.queueAudio() await foundation.orchestrator.processTracks() await foundation.orchestrator.scopedTracks() await foundation.orchestrator.scrobbleAudio() await foundation.orchestrator.sources() await foundation.orchestrator.artwork()

Examples

Some simple examples to help you understand how to build your own facet. Click the edit button to load them into the code editor above.

  • Shows what's currently set to "now playing" in the queue, along with a button to shift the queue to the next track.
  • Make a list of what previously played in the queue.

Notes

While you have the ability to do whatever you want in a custom facet, the existing facets are designed to work a certain way; so here's some things to keep in mind:

  • Prelude (feature) facets are loaded in alphabetical order by the facet loader.
  • Most elements are configured in broadcast mode so they communicate across tabs. There are a few exceptions such as inputs, where we prefer parallelisation.
  • All URLs in a facet are relative to the root of Diffuse (not the root of the server) due to the base element in the header of the facet loader.