Skip to content

Menus and Miscellaneous APIs

This page covers the fb.menu, fb.console, fb.log, fb.lyrics, fb.notification, fb.panel, fb.misc, and fb.dnd namespaces.

fb.menu Menu Commands

getMainMenu(root?)

Returns the main-menu tree. The optional root scopes the returned subtree, for example 'Main' or 'View'.

javascript
const menu = await fb.menu.getMainMenu();
const viewMenu = await fb.menu.getMainMenu('View');

getContextMenu(options?)

Returns a context-menu tree.

ParameterTypeDescription
options.mode'auto' | 'selection' | 'playlist' | 'nowPlaying' | 'handles'Selects the context source.
options.handlesunknown[]Handle list used with mode: 'handles'.
options.pathstringOptional track path.
options.subsongnumberOptional subsong index.
options.localestringLocale selector; defaults to 'auto'.
options.i18nbooleanEnables localized labels.
options.withAvailabilitybooleanIncludes availability metadata.
javascript
const ctx = await fb.menu.getContextMenu({ mode: 'nowPlaying' });

Use selection for selected tracks. playlist requests playlist-level commands.

runMainMenuCommand(command)

Executes a main-menu command by path.

javascript
await fb.menu.runMainMenuCommand('File/Preferences');

runContextCommand(command)

Executes a context-menu command against the default context.

javascript
await fb.menu.runContextCommand('Properties');

runContextCommandById(id, options?)

Executes a context-menu command by numeric ID.

ParameterTypeDescription
idnumberCommand ID.
optionsOmit<MenuRunContextCommandByIdParams, 'id'>Optional mode, handles, path, and subsong context.

showNativePopup(options?)

Schedules a native popup menu using MenuShowNativePopupParams. The default auto mode tries handles, now playing, playlist selection, then playlist context.

javascript
await fb.menu.showNativePopup({ mode: 'selection' });

For the WebView-rendered menu.show, menu.close, and menu.popup APIs, see fb.menu.

fb.console Console Output

Writes messages to the foobar2000 console. Each method returns a Promise<BaseResponse>.

log(message)

javascript
await fb.console.log('Debug information');

warn(message)

javascript
await fb.console.warn('Warning message');

error(message)

javascript
await fb.console.error('Error message');

fb.log Log File

write(message, options?)

Writes a message with optional LogWriteParams, including level, append, timestamp, file, and args. The response may include the log-file path.

javascript
await fb.log.write('Operation completed', { level: 'info' });

read(lines?)

Reads log lines. The default host limit is 100 when lines is omitted.

javascript
const { lines } = await fb.log.read(100);

clear()

Clears the log file.

javascript
await fb.log.clear();

fb.lyrics Lyrics

get(path?, options?)

Returns lyrics for path, or for the current track when path is omitted.

ParameterTypeDescription
pathstringOptional track path.
options.source'embedded' | 'file' | 'any'Source filter; defaults to 'any'.
options.type'synced' | 'unsynced' | 'any'Synchronization filter; defaults to 'any'.
options.format'lrc' | 'txt' | 'any'File-format filter; defaults to 'any'.
javascript
const current = await fb.lyrics.get();
const embedded = await fb.lyrics.get(path, { source: 'embedded' });
const synced = await fb.lyrics.get(undefined, { type: 'synced' });

exists(path)

Checks whether lyrics are available for a track path.

javascript
const r = await fb.lyrics.exists('E:\\\\Music\\\\song.flac');
console.log(r.exists);

save(path, lyrics, options?)

Saves lyrics to one or more configured targets.

ParameterTypeDescription
pathstringTrack path.
lyricsstringLyrics text.
options.targetstring[]Target list forwarded by LyricsSaveParams.
options.filenamestringOptional custom sidecar filename.
options.tagNamestringEmbedded tag name; defaults to 'LYRICS'.
options.formatstringSidecar format; defaults to 'lrc'.
javascript
await fb.lyrics.save('E:\\\\Music\\\\song.flac', '[00:00.00]Lyrics...');
await fb.lyrics.save(path, text, { target: ['file', 'config'] });
await fb.lyrics.save(path, text, {
    target: ['embedded'],
    tagName: 'SYNCEDLYRICS',
});

The SDK return type is BaseResponse & { results?: Array<{ target, success, error? }>; savedTo?: string[] }.

fb.notification Notifications

show(options)

Shows a host notification. UiShowNotificationParams uses body, not message.

javascript
await fb.notification.show({ title: 'Notice', body: 'Operation completed' });

hide()

Hides the current notification.

showCustomMenu(options)

Shows a host custom menu and returns optional selectedId.

javascript
const { selectedId } = await fb.notification.showCustomMenu({
    items: [
        { label: 'Option A', id: 'a' },
        { label: 'Option B', id: 'b' },
    ],
});

showToast(options)

Shows a toast.

javascript
await fb.notification.showToast({ message: 'Added to the playlist' });

fb.panel Panel Configuration

getConfig()

Returns the current panel configuration envelope.

javascript
const { config } = await fb.panel.getConfig();

setConfig(options)

Updates fields supported by PanelSetConfigParams: panelName, transparentBackground, grabFocus, and enableDragDrop.

javascript
await fb.panel.setConfig({ panelName: 'Library', enableDragDrop: true });

fb.misc Host Actions

exit()

Exits foobar2000.

restart()

Restarts foobar2000.

javascript
await fb.misc.restart();

getComponentPath()

Returns { path } for the component DLL directory.

javascript
const r = await fb.misc.getComponentPath();
console.log(r.path);

getFoobarPath()

Returns { path } for the foobar2000 executable directory.

getProfilePath()

Returns { path } for the profile directory.

showConsole()

Shows the foobar2000 console window.

showLibrarySearch(query?)

Opens Media Library Search with an optional initial query.

javascript
await fb.misc.showLibrarySearch('artist IS Beatles');

showPopupMessage(message, title?)

Shows a popup message box.

javascript
await fb.misc.showPopupMessage('Operation completed', 'Notice');

showPreferences()

Opens foobar2000 Preferences.

fb.dnd Drag and Drop

registerDropZone(options)

Registers a drop zone. DndRegisterDropZoneParams accepts selector, event, and accept; the host returns { zoneId }.

javascript
const { zoneId } = await fb.dnd.registerDropZone({
    selector: '#drop-area',
    event: 'dnd:drop',
    accept: ['audio/*'],
});

unregisterDropZone(zoneId)

Unregisters a drop zone by the ID returned from registerDropZone().

javascript
await fb.dnd.unregisterDropZone(zoneId);

startDrag(type, options?)

Starts a drag operation.

ParameterTypeDescription
typestringDrag type.
optionsOmit<DndStartDragParams, 'type'>Optional data and paths payload.

getDropZones()

Returns { success, zones, count }. Each DropZone contains id, selector, accept, and event.

javascript
const zones = await fb.dnd.getDropZones();

SDK Method Stubs

This block maintains SDK-facing method coverage and may be expanded with complete examples and best practices.

exit()

Signature: fb.misc.exit(): Promise<BaseResponse>

ParameterTypeRequiredDescription
NoneThis method takes no arguments.

Returns the misc.exit response envelope.

javascript
const result = await fb.misc.exit();

getFoobarPath()

Signature: fb.misc.getFoobarPath(): Promise<{ path: string }>

ParameterTypeRequiredDescription
NoneThis method takes no arguments.

Returns the foobar2000 path in { path }.

javascript
const result = await fb.misc.getFoobarPath();

getProfilePath()

Signature: fb.misc.getProfilePath(): Promise<{ path: string }>

ParameterTypeRequiredDescription
NoneThis method takes no arguments.

Returns the profile path in { path }.

javascript
const result = await fb.misc.getProfilePath();

showConsole()

Signature: fb.misc.showConsole(): Promise<BaseResponse>

ParameterTypeRequiredDescription
NoneThis method takes no arguments.

Returns the misc.showConsole response envelope.

javascript
const result = await fb.misc.showConsole();

showPreferences()

Signature: fb.misc.showPreferences(): Promise<BaseResponse>

ParameterTypeRequiredDescription
NoneThis method takes no arguments.

Returns the misc.showPreferences response envelope.

javascript
const result = await fb.misc.showPreferences();