Add your own user interface
Ship a complete web user interface in your plugin, and let users pick it in place of the one that ships with Volumio. The interface is a folder of web files inside your plugin. The plugin registers it when it starts.
Prerequisites
- A plugin of type
user_interface. - A built web interface: a folder with an
index.htmland the files it loads. - A way for users to switch back. Your interface must let the user choose another interface, as Volumio's own settings do.
1. Put the interface in the plugin
Put the built interface in a folder of your plugin, such as ui/. On the device, the plugin lives in /data/plugins/user_interface/<id>/, so the folder is /data/plugins/user_interface/<id>/ui.
2. Register it when the plugin starts
In onStart, call registerThirdPartyUI:
index.js
onStart() {
this.commandRouter.registerThirdPartyUI({
uiPrettyName: 'Now Playing',
uiName: 'now-playing',
uiPath: path.join(__dirname, 'ui'),
});
return libQ.resolve();
}
Every field is required:
| Field | Value |
|---|---|
uiPrettyName | The name users see when they pick an interface |
uiName | A short name in lowercase, without spaces |
uiPath | The absolute path of the interface's folder on the device |
Volumio checks that uiPath exists before it adds the interface. Each registration is saved in /data/thirdPartyUisList.json. An interface whose folder is gone, such as after the plugin is uninstalled, no longer appears in the list.
Check that it works
- Install the plugin with
npx --package=@volumio/plugin-sdk volumio-plugin deploy 192.168.1.20 .. - In the device log, find
Registering Third Party UIfollowed by your fields. - In the Volumio settings, open the Appearance page. Your interface is among the ones users can pick.
If the interface does not appear
| Log line | Cause | Fix |
|---|---|---|
Failed to register UI: <path> does not exist | uiPath points to a folder that is not on the device | Build the interface into the plugin folder, and pass its absolute path |
Failed to register UI: missing uiName, uiPath or uiPrettyName | A field is missing or empty | Pass all three fields |