Racelink
Documentation · Pictures and sounds of the player

// Documentation · Avancé

Pictures and sounds of the player

A logo of the team, a background, a horn: files a player picks from their computer in the overlay’s settings.

Ce guide n’existe pour l’instant qu’en anglais.

Declare a file setting

A setting of type image holds a picture, one of type audio a sound. Neither has a default: only the player picks a file, and until then the overlay shows or plays its own.

racelink.overlay.json
{
"key": "background",
"label": "Background picture",
"type": "image",
"description": "Shown behind the board"
}

In the overlay’s settings Racelink shows a button that opens the system file picker, a preview of the chosen file and a button to remove it.

What the player can pick

  • image: PNG, JPEG, WebP or GIF, up to 10 MB. SVG is not accepted.
  • audio: MP3, Ogg or WAV, up to 20 MB.

Racelink checks that the content of the file is what its extension says and keeps its own copy, so moving or deleting the original changes nothing.

Use the file

The setting’s value is a name Racelink gave the copy, or '' while nothing is picked. settingFileUrl(value) turns it into an address the overlay can load, or null for nothing picked:

src/main.ts
import { settingFileUrl } from '@racelink/overlay';

overlay.on('settings', (settings) => {
const url = settingFileUrl(settings.background);
root.style.backgroundImage = url ? `url("${url}")` : '';
});
src/App.tsx
import { settingFileUrl } from '@racelink/overlay';

const url = settingFileUrl(settings.background);
return url ? <img src={url} alt="" /> : <DefaultBackground />;

A sound plays the same way, when the overlay may make sound:

src/main.ts
const url = settingFileUrl(overlay.settings.horn);
if (url && overlay.soundAllowed) void new Audio(url).play();