Extensions/Assessment/whiteNoise

Extensions add specific functionality to Items API. They rely on modules within LT being available.

--

Renders an audio player that the end-user can use to play white noise sounds. Helps for some users with focus and concentration.

By default the player renders inside a custom dialog from Items API. This is the simplest set up, just call run() and add something like the following to your Items API config object (the essential piece is the custom button):

{
    "config": {
        "regions": "main",
        "region_overrides": {
            "right": [
                {
                    "type": "save_button"
                },
                {
                    "type": "fullscreen_button"
                },
                {
                    "type": "reviewscreen_button"
                },
                {
                    "type": "accessibility_button"
                },
                {
                    "type": "flagitem_button"
                },
                {
                    "type": "custom_button",
                    "options": {
                        "name": "btn-whitenoise",
                        "label": "White noise player",
                        "icon_class": "lt__whitenoise-player-icon"
                    }
                },
                {
                    "type": "masking_button"
                }
            ]
        }
    }
}

This will render a button in the vertical toolbar of the player with a headphones icon. Click this and the player will launch (see below).

If you want to render the player inside a custom element, pass an id to launchPlayer(id) after calling run(). This will render the player inside an element of your choice. You will be responsible for showing/hiding the player, or just leave it always visible.

<div id="player-wrapper"></div>
<div id="learnosity_assess"></div>

<script>
  LT.init(app);
  LT.extensions.whiteNoise.run();

  // Trigger this on a click event or anything defining when
  // you want to load the white noise player
  LT.extensions.whiteNoise.launchPlayer('player-wrapper');
</script>

Methods

launchPlayer()

Launches the white noise audio player. Defaults to rendering inside an Items API custom dialog, in which case you never need to call this method directly.

Since
2.7.0

run(idopt, shadowRootopt)

Sets up the white noise audio player.

Since
2.7.0
Example
import { LT } from '@caspingus/lt/src/assessment/index';

LT.init(itemsApp); // Set up LT with the Items API application instance variable
LT.extensions.whiteNoise.run();
Parameters:
Name Type Attributes Description
id string <optional>

Optional id of an element, or element, to render the player into

shadowRoot object <optional>

Optional A shadow root to render the player into