Documentation/fb
namespaceWORKER

fb

js/foo_uie_jsplitter.js:519

Functions for controlling foobar2000 and accessing it's data.

propertyWORKERMAIN THREAD

AlwaysOnTop

js/foo_uie_jsplitter.js:526
AlwaysOnTop: boolean

Example

fb.AlwaysOnTop = !fb.AlwaysOnTop; // Toggles the current value.
propertyWORKERreadonly

ComponentPath

js/foo_uie_jsplitter.js:545
ComponentPath: string

Example

console.log(fb.ComponentPath); // C:\Users\User\AppData\Roaming\foobar2000\user-components\foo_uie_jsplitter\
propertyWORKERMAIN THREAD

CursorFollowPlayback

js/foo_uie_jsplitter.js:555
CursorFollowPlayback: boolean
propertyWORKERMAIN THREADreadonly

CustomVolume

js/foo_uie_jsplitter.js:562
CustomVolume: boolean

It can be used for displaying the volume from UPnP devices.
It will return a value of -1 when using a normal device and that also indicates that fb.Volume is writable.
When a custom volume control is active, you can not use fb.Volume and must use fb.VolumeUp / fb.VolumeDown / fb.VolumeMute.

propertyWORKERreadonly

FoobarPath

js/foo_uie_jsplitter.js:573
FoobarPath: string
propertyWORKERMAIN THREADreadonly

IsPaused

js/foo_uie_jsplitter.js:580
IsPaused: boolean
propertyWORKERMAIN THREADreadonly

IsPlaying

js/foo_uie_jsplitter.js:588
IsPlaying: boolean
propertyWORKERMAIN THREAD

PlaybackFollowCursor

js/foo_uie_jsplitter.js:596
PlaybackFollowCursor: boolean
propertyWORKERMAIN THREADreadonly

PlaybackLength

js/foo_uie_jsplitter.js:603
PlaybackLength: float

Examples

console.log(fb.PlaybackLength); // 322.843414966166
console.log(Math.round(fb.PlaybackLength)); // 323
propertyWORKERMAIN THREAD

PlaybackTime

js/foo_uie_jsplitter.js:617
PlaybackTime: float

Example

fb.PlaybackTime = 60; // Jumps to the 1 minute mark.
propertyWORKERreadonly

ProfilePath

js/foo_uie_jsplitter.js:627
ProfilePath: string
propertyWORKERMAIN THREAD

ReplaygainMode

js/foo_uie_jsplitter.js:634
ReplaygainMode: number

0 - None
1 - Track
2 - Album
3 - Track/Album by Playback Order (only available in foobar2000 v1.3.8 and later) See ReplayGainMode enum

Throws

Error —

If the assigned value is not a valid replay gain mode.

propertyWORKERMAIN THREAD

StopAfterCurrent

js/foo_uie_jsplitter.js:648
StopAfterCurrent: boolean

Example

fb.StopAfterCurrent = !fb.StopAfterCurrent; // Toggles the current value.
propertyWORKERreadonly

Version

js/foo_uie_jsplitter.js:658
Version: string

Example

console.log(fb.Version)
// 1.4.1
propertyWORKERMAIN THREAD

Volume

js/foo_uie_jsplitter.js:669
Volume: float

Example

fb.Volume = 0; // Sets the volume to max. -100 is the minimum.
propertyreadonly

Window

js/foo_uie_jsplitter.js:536
Window: FbWindow

Access to the main foobar2000 application window. See FbWindow for global state, multi-panel ownership and UI-specific behavior.

methodWORKERMAIN THREAD

AcquireUiSelectionHolder

js/foo_uie_jsplitter.js:679
AcquireUiSelectionHolder()

Returns

FbUiSelectionHolder
method

AddDirectory

js/foo_uie_jsplitter.js:686
AddDirectory()
method

AddFiles

js/foo_uie_jsplitter.js:689
AddFiles()
methodWORKERMAIN THREAD

AddLocationsAsync

js/foo_uie_jsplitter.js:692
AddLocationsAsync(locations)

Converts one or more paths to a list of metadb_handles.
The function returns immediately; specified callback on_locations_added receives results when the operation has completed.

Relative filesystem paths are resolved as described in utils.ReadTextFile. URLs and foobar2000 URI paths are passed through unchanged. Each filesystem location is resolved before the asynchronous operation starts.

Parameters

NameTypeDescription
locationsArray<string>

must be an array of strings and it can contain file paths, playlists or urls.

Returns

number —

task id (see first parameter of on_locations_added)

Throws

Error —

If called before foobar2000 is fully initialized.

Example

function on_mouse_lbtn_dblclk() {
    var files = ["z:\\1.mp3", "z:\\2.flac"];
    var task_id = fb.AddLocationsAsync(files);
    console.log("got task_id", task_id);
}

function on_locations_added(task_id, handle_list) {
    console.log("callback task_id", task_id);
    console.log(handle_list.Count);
}
methodWORKERMAIN THREAD

CheckClipboardContents

js/foo_uie_jsplitter.js:718
CheckClipboardContents()

Checks Clipboard contents are handles or a file selection from Windows Explorer. Use in conjunction with fb.GetClipboardContents.

Returns

boolean
methodWORKERMAIN THREAD

ClearPlaylist

js/foo_uie_jsplitter.js:728
ClearPlaylist()

Clears active playlist.
If you wish to clear a specific playlist, use plman.ClearPlaylist(playlistIndex).

methodWORKERMAIN THREAD

CopyHandleListToClipboard

js/foo_uie_jsplitter.js:736
CopyHandleListToClipboard(handle_list)

Note: items can then be pasted in other playlist viewers or in Windows Explorer as files.

Parameters

NameTypeDescription
handle_listFbMetadbHandleList

Returns

boolean

Throws

Error —

If handle_list is null.

Examples

Copy playlist items
let handle_list = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
fb.CopyHandleListToClipboard(handle_list);
Cut playlist items
let ap = plman.ActivePlaylist;
if (!plman.GetPlaylistLockedActions(ap).includes('RemoveItems')) {
   let handle_list = plman.GetPlaylistSelectedItems(ap);
   if (fb.CopyHandleListToClipboard(handle_list)) {
       plman.UndoBackup(ap);
       plman.RemovePlaylistSelection(ap);
   }
 }
method

CreateContextMenuManager

js/foo_uie_jsplitter.js:761
CreateContextMenuManager()

Returns

ContextMenuManager

Example source

methodWORKERdeprecated

CreateHandleList

js/foo_uie_jsplitter.js:768
CreateHandleList()
Deprecated.

Returns an empty handle list.
Deprecated: use FbMetadbHandleList constructor instead.

Returns

FbMetadbHandleList
method

CreateMainMenuManager

js/foo_uie_jsplitter.js:779
CreateMainMenuManager()

Returns

MainMenuManager

Example source

methodWORKER

CreateProfiler

js/foo_uie_jsplitter.js:786
CreateProfiler(name)

Parameters

NameTypeDescription
name = ''optionalstring

Will be shown in console when used with Print method.

Returns

FbProfiler
method

DoDragDrop

js/foo_uie_jsplitter.js:793
DoDragDrop(window_id, handle_list, effect, options)

Invokes drag-n-drop operation (see https://docs.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-dodragdrop).

Quick tips:
- If you need only to drag from your panel with copy (i.e. without physically moving them): use only fb.DoDragDrop(handles, DROPEFFECT_COPY | DROPEFFECT_LINK).
- If you need only to receive drop to your panel with copy: handle on_drop_*() callbacks, while setting action.effect argument to (DROPEFFECT_COPY | DROPEFFECT_LINK).

Full drag-n-drop interface description:
- Drag-n-drop interface is based on Microsoft IDropSource and IDropTarget interfaces, so a lot of info (including examples) could be gathered from MSDN (IDropSource, IDropTarget, DoDragDrop, DROPEFFECT).
- Drag operation is started with DoDragDrop (whether it is called by your panel, or externally) with okEffects argument supplied.
- DoDragDrop blocks code execution until the drag operation is finished (callbacks will be called properly though). It returns effect from Action.Effect from on_drag_drop after completion.
- (Spider Monkey Panel specific) Drag operation is canceled when any mouse button is pressed.
- (Spider Monkey Panel specific) All mouse callbacks are suppressed during drag operation (including on_mouse_lbtn_up, but excluding on_mouse_mbtn_up and on_mouse_rbtn_up).
- Every drag callback receives Action argument. Action.Effect contains okEffects from DoDragDrop call. Action.Effect should be changed to the desired effect in the callback. If the returned Action.Effect was not in okEffects or is equal to DROPEFFECT_NONE (=== 0), then drop will be denied: cursor icon will be changed, on_drag_drop won't be called after releasing lmbtn, on_drag_leave will be called instead.
- DROPEFFECT_LINK should be used as fallback in case effect argument does not have DROPEFFECT_COPY (===1), since some external drops only allow DROPEFFECT_LINK effect.
- Changing effect on key modifiers is nice (to be in line with native Windows behaviour): see the example below.

Note: due to the asynchronous nature of event handling, fb.DoDragDrop might exit before on_drag_drop callback is triggered when dropping data on the same panel as the one that had a call to fb.DoDragDrop.

Related callbacks: on_drag_enter, on_drag_drop, on_drag_over, on_drag_leave

Parameters

NameTypeDescription
window_idnumber

unused

handle_listFbMetadbHandleList
effectnumber

Allowed effects.

options = undefinedoptionalobject

Customization options for the data displayed in the drag window.

options.show_text = trueoptionalboolean

If true, will add track count text.

options.use_album_art = trueoptionalboolean

If true, will use album art of the focused item from dragged tracks (if available)

options.use_theming = trueoptionalboolean

If true, will use Windows drag window style. Album art and custom image are resized to fit when Windows style is active.

options.custom_image = undefinedoptionalGdiBitmap

(or D2DBitmap if window.DrawMode == 1). Custom dragging image. Will be also displayed if use_album_art is true, but there is no album art available.

Returns

number —

Effect that was returned in on_drag_drop.

Throws

Error —

If handle_list is null, options is not an object, or the panel host is not fully initialized.

Example source

methodWORKER

EnableAdvancedLogging

js/foo_uie_jsplitter.js:842
EnableAdvancedLogging()

For future development purposes (e.g. verbose console output)

methodWORKERMAIN THREAD

EnumerateMainMenuCommands

js/foo_uie_jsplitter.js:850
EnumerateMainMenuCommands()

Returns all main menu items recursivley.
It is a JSON array in string form so you need to use JSON.parse on the result.
Every item of the array is object with the following properties:
Checked: boolean
Disabled: boolean
FullPath: string, the same full path you'd supply to fb.RunMainMenuCommand
HiddenByDefault: boolean
Radio: boolean
Type: string ("Fixed" or "Dynamic")
Visible: boolean

Returns

string

Example

const menuCommands = JSON.parse(fb.EnumerateMainMenuCommands());

// list all checked commands in the console
menuCommands
    .filter(command => command.Checked)
    .forEach(({ FullPath }) => console.log(FullPath));
methodWORKERMAIN THREAD

Exit

js/foo_uie_jsplitter.js:835
Exit()
methodWORKERMAIN THREAD

GetActiveDSPs

js/foo_uie_jsplitter.js:876
GetActiveDSPs()

Returns array of active DSPs names.

Returns

Array<string>
methodWORKER

GetAudioChunk

js/foo_uie_jsplitter.js:910
GetAudioChunk(requested_length, offset)

Returns PCM data from the foobar2000 visualisation stream.
The stream is created lazily. A negative offset requests data before the current visualisation time; JSplitter automatically maintains the native backlog required for that offset. The first stream initialization may briefly synchronize with the foobar2000 main thread.
For repeated real-time processing, prefer fb.GetAudioChunkTo to write directly into a reusable Float32Array without creating a transient FbAudioChunk. CopyDataTo remains useful when a chunk object is already required, while Data preserves its legacy allocating Array behaviour for compatibility.

Parameters

NameTypeDescription
requested_lengthnumber
offset = 0optionalnumber

Returns

FbAudioChunk

Throws

Error —

If the foobar2000 visualisation stream cannot be created.

Example source

methodWORKER

GetAudioChunkTo

js/foo_uie_jsplitter.js:925
GetAudioChunkTo(destination, requested_length, offset, info)

Writes interleaved PCM samples from the foobar2000 visualisation stream directly into an existing Float32Array. Unlike fb.GetAudioChunk, this method does not create an FbAudioChunk; after the first sufficiently large native scratch buffer has been established, repeated calls can reuse both the native scratch storage and the JavaScript destination buffer.
A negative offset has the same backlog semantics as fb.GetAudioChunk. If info is supplied, it is updated in place with SampleCount, ChannelCount, SampleRate and ChannelConfig.

Parameters

NameTypeDescription
destinationFloat32Array

Destination buffer. It must have room for all interleaved PCM sample values.

requested_lengthnumber
offset = 0optionalnumber
infooptionalObject

Reusable metadata object updated in place.

Returns

number —

Number of scalar PCM samples written, or 0 when no chunk is currently available.

Throws

Error —

If the foobar2000 visualisation stream cannot be created, destination is not a Float32Array or is too small, or info is not an object.

methodWORKER

GetAudioStreams

js/foo_uie_jsplitter.js:885
GetAudioStreams(handle)

Returns the audio streams exposed by the input decoder for handle as array of AudioStreamInfo objects.
Returns an empty array when the file's input decoder does not expose stream information. Related methods: fb.SetAudioStream.

Parameters

NameTypeDescription
handleFbMetadbHandle

Returns

Array<AudioStreamInfo>

Throws

Error —

If handle is null or foobar2000's input stream selector is unavailable.

Example

const handle = fb.GetFocusItem();
if (handle) {
    const streams = fb.GetAudioStreams(handle);
    for (const stream of streams) {
        console.log(`#${stream.index}: default=${stream.default}, selected=${stream.selected}`);
        for (let i = 0; i < stream.info.InfoCount; ++i) {
            console.log(`  ${stream.info.InfoName(i)}=${stream.info.InfoValue(i)}`);
        }
    }
}

Example source

methodWORKERMAIN THREAD

GetClipboardContents

js/foo_uie_jsplitter.js:940
GetClipboardContents(window_id)

Note: clipboard contents can be handles copied to the clipboard in other components, from fb.CopyHandleListToClipboard or a file selection, from Windows Explorer and etc.

Performance note: validate clipboard content with fb.CheckClipboardContents before calling this method.

Parameters

NameTypeDescription
window_id = 0optionalnumber

unused

Returns

FbMetadbHandleList

Throws

Error —

If called before foobar2000 is fully initialized.

Example

function on_mouse_rbtn_up(x, y) {
   let ap = plman.ActivePlaylist;
   let menu = window.CreatePopupMenu();
   menu.AppendMenuItem(!plman.GetPlaylistLockedActions(ap).includes('AddItems') && fb.CheckClipboardContents() ? MF_STRING : MF_GRAYED, 1, "Paste"); // see Flags.js for MF_* definitions
   let idx = menu.TrackPopupMenu(x, y);
   if (idx == 1) {
       let handle_list  = fb.GetClipboardContents();
       plman.InsertPlaylistItems(ap, plman.PlaylistItemCount(ap), handle_list );
   }
   return true;
}
methodWORKERMAIN THREAD

GetDSPPresets

js/foo_uie_jsplitter.js:967
GetDSPPresets()

Available only in foobar2000 v1.4 and above. Throws a script error on v1.3. *
Returns a JSON array in string form so you need to use JSON.parse() on the result.
Related methods: fb.SetDSPPreset.

Returns

string

Example

let str = fb.GetDSPPresets();
let arr = JSON.parse(str);
console.log(JSON.stringify(arr, null, 4));
// [
//     {
//         "active": false,
//         "name": "High Filter"
//     },
//     {
//         "active": true,
//         "name": "R128 Compressor"
//     },
//     {
//         "active": false,
//         "name": "7.1 upmix"
//     }
// ]
methodWORKERMAIN THREAD

GetFocusItem

js/foo_uie_jsplitter.js:998
GetFocusItem(force)

Parameters

NameTypeDescription
force = trueoptionalboolean

When true, it will use the first item of the active playlist if it is unable to get the focus item.

Returns

FbMetadbHandle
methodWORKERMAIN THREAD

GetLibraryItems

js/foo_uie_jsplitter.js:1006
GetLibraryItems()

Returns all Media Library items as a handle list.

Returns

FbMetadbHandleList
methodWORKERMAIN THREAD

GetLibraryRelativePath

js/foo_uie_jsplitter.js:1015
GetLibraryRelativePath(handle)

Note: do not use this while looping through a handle list. Use GetLibraryRelativePaths instead.

Returns an empty string when used on track not in Media Library

Parameters

NameTypeDescription
handleFbMetadbHandle

Returns

string

Throws

Error —

If handle is null.

Example

// The foobar2000 Media Library is configured to watch "D:\Music" and the
// path of the now playing item is "D:\Music\Albums\Artist\Some Album\Some Song.flac"
let handle = fb.GetNowPlaying();
console.log(fb.GetLibraryRelativePath(handle)); // Albums\Artist\Some Album\Some Song.flac*
methodWORKERMAIN THREAD

GetLibraryRoots

js/foo_uie_jsplitter.js:1034
GetLibraryRoots()

Returns unique Media Library root paths inferred from the current Media Library contents.
Each root is reconstructed from the absolute path and library-relative path of a library item.
Configured library folders that contain no library items cannot be returned.

Returns

Array<string> —

Media Library root paths

methodWORKERMAIN THREAD

GetNowPlaying

js/foo_uie_jsplitter.js:1045
GetNowPlaying()

Get handle of the now playing track.

Returns

?FbMetadbHandle —

null, if nothing is being played.

methodWORKER

GetOutputDevices

js/foo_uie_jsplitter.js:1054
GetOutputDevices()

Available only in foobar2000 v1.4 and above. Throws a script error on v1.3. *
Returns a JSON array in string form so you need to use JSON.parse() on the result.
Related methods: fb.SetOutputDevice.

Returns

string

Example

let str = fb.GetOutputDevices();
let arr = JSON.parse(str);
console.log(JSON.stringify(arr, null, 4));
// [
//     {
//         "active": false,
//         "device_id": "{5243F9AD-C84F-4723-8194-0788FC021BCC}",
//         "name": "Null Output",
//         "output_id": "{EEEB07DE-C2C8-44C2-985C-C85856D96DA1}"
//     },
//     {
//         "active": true,
//         "device_id": "{00000000-0000-0000-0000-000000000000}",
//         "name": "Primary Sound Driver",
//         "output_id": "{D41D2423-FBB0-4635-B233-7054F79814AB}"
//     },
//     {
//         "active": false,
//         "device_id": "{1C4EC038-97DB-48E7-9C9A-05FDED46847B}",
//         "name": "Speakers (Sound Blaster Z)",
//         "output_id": "{D41D2423-FBB0-4635-B233-7054F79814AB}"
//     },
//     {
//         "active": false,
//         "device_id": "{41B86272-3D6C-4A5A-8907-4FE7EBE39E7E}",
//         "name": "SPDIF-Out (Sound Blaster Z)",
//         "output_id": "{D41D2423-FBB0-4635-B233-7054F79814AB}"
//     },
//     {
//         "active": false,
//         "device_id": "{9CDC0FAE-2870-4AFA-8287-E86099D69076}",
//         "name": "3 - BenQ BL3200 (AMD High Definition Audio Device)",
//         "output_id": "{D41D2423-FBB0-4635-B233-7054F79814AB}"
//     }
// ]
// Normally, one item in the array has "active" set to true,
// indicating the currently configured output device.
// If the configured output device is unavailable, the array
// may contain no active item.
methodWORKER

GetQueryItems

js/foo_uie_jsplitter.js:1106
GetQueryItems(handle_list, query)

Note: use try/catch to handle invalid queries. An empty handle list will be returned if the query is valid but there are no results.

Parameters

NameTypeDescription
handle_listFbMetadbHandleList
querystring

Returns

FbMetadbHandleList —

Unsorted results.

Throws

Error —

If handles is null or the query cannot be parsed or processed.

Examples

let a = fb.GetQueryItems(plman.GetPlaylistItems(plman.ActivePlaylist), "rating IS 5");
let b = fb.GetQueryItems(fb.GetLibraryItems(), "rating IS 5");
methodWORKERMAIN THREAD

GetSelection

js/foo_uie_jsplitter.js:1124
GetSelection()

Gets now playing or selected item according to settings in "File>Preferences>Display>Selection viewers".

Returns

?FbMetadbHandle
methodWORKERMAIN THREAD

GetSelections

js/foo_uie_jsplitter.js:1133
GetSelections(flags)

Works like fb.GetSelection, but returns a handle list.

Parameters

NameTypeDescription
flags = 0optionalnumber

1 - no now playing

Returns

FbMetadbHandleList
methodWORKERMAIN THREAD

GetSelectionType

js/foo_uie_jsplitter.js:1143
GetSelectionType()

Retrieves what the selection type is.

Returns

number —

see SelectionType enum
0 - undefined (no item)
1 - active_playlist_selection
2 - caller_active_playlist
3 - playlist_manager
4 - now_playing
5 - keyboard_shortcut_list
6 - media_library_viewer

methodWORKERMAIN THREAD

IsLibraryEnabled

js/foo_uie_jsplitter.js:1159
IsLibraryEnabled()

Returns

boolean
methodWORKER

IsLibraryInitialised

js/foo_uie_jsplitter.js:1166
IsLibraryInitialised()

Returns true if the library has already been initialized by this time

Returns

boolean
methodWORKERMAIN THREAD

IsMainMenuCommandChecked

js/foo_uie_jsplitter.js:1174
IsMainMenuCommandChecked(command)

Performance note: don't use in on_paint.

Parameters

NameTypeDescription
commandstring

Path to main menu item

Returns

boolean —

true, if the item is checked.

Example

fb.RunMainMenuCommand("Playback/Scrobble Tracks"); // available with foo_scrobble
methodWORKERMAIN THREAD

IsMetadbInMediaLibrary

js/foo_uie_jsplitter.js:1187
IsMetadbInMediaLibrary(handle)

Parameters

NameTypeDescription
handleFbMetadbHandle

Returns

boolean

Throws

Error —

If handle is null.

Example

let np = fb.GetNowplaying();
console.log(fb.IsMetadbInMediaLibrary(np)); // If false, playing track is not in Media Library.
method

LoadPlaylist

js/foo_uie_jsplitter.js:1200
LoadPlaylist()

Loads playlist from file. Equivalent to File>Load Playlist....

methodWORKERMAIN THREAD

Next

js/foo_uie_jsplitter.js:1207
Next()
methodWORKERMAIN THREAD

Pause

js/foo_uie_jsplitter.js:1214
Pause()
methodWORKERMAIN THREAD

Play

js/foo_uie_jsplitter.js:1221
Play()
methodWORKERMAIN THREAD

PlayOrPause

js/foo_uie_jsplitter.js:1228
PlayOrPause()
methodWORKERMAIN THREAD

Prev

js/foo_uie_jsplitter.js:1235
Prev()
methodWORKERMAIN THREAD

Random

js/foo_uie_jsplitter.js:1242
Random()
methodWORKERMAIN THREAD

RegisterMainMenuCommand

js/foo_uie_jsplitter.js:1249
RegisterMainMenuCommand(id, name, description)

Registers a main menu item that will be displayed under main menu > File > JSplitter > Script commands > {Current panel name}.
Being main menu item means you can bind it to global keyboard shortcuts, standard toolbar buttons, panel stack splitter buttons and etc.
Execution of the correspoding menu item will trigger on_main_menu_dynamic callback.

Note: JSplitter uses a combination of panel name and command id to identify and bind the command. Hence all corresponding binds will fail if the id or the panel name is changed. This also means that collision WILL occur if there are two panels with the same name.

Related methods: fb.UnregisterMainMenuCommand
Related callbacks: on_main_menu_dynamic

Parameters

NameTypeDescription
idnumber
namestring
description = ''optionalstring

Throws

Error —

If the panel host is not fully initialized, the command id is already registered, or the command cannot be registered.

methodWORKERMAIN THREAD

Restart

js/foo_uie_jsplitter.js:1269
Restart()
method

RunContextCommand

js/foo_uie_jsplitter.js:1276
RunContextCommand(command, flags)

Shows context menu for currently played track.

Parameters

NameTypeDescription
commandstring
flags = 0optionalnumber

0 - default (depends on whether SHIFT key is pressed, flag_view_reduced or flag_view_full is selected)
4 - flag_view_reduced
8 - flag_view_full. This can be useful if you need to run context commands the user may have hidden using File>Preferences>Display>Context Menu

Returns

boolean

Example

fb.RunContextCommand("Properties");
method

RunContextCommandWithMetadb

js/foo_uie_jsplitter.js:1292
RunContextCommandWithMetadb(command, handle_or_handle_list, flags)

Shows context menu for supplied tracks.

Parameters

NameTypeDescription
commandstring
handle_or_handle_listFbMetadbHandle|FbMetadbHandleList

Handles on which to apply context menu

flagsoptionalnumber

Same flags as fb.RunContextCommand

Returns

boolean

Throws

Error —

If handle_or_handle_list is not an FbMetadbHandle or FbMetadbHandleList object.

method

RunMainMenuCommand

js/foo_uie_jsplitter.js:1303
RunMainMenuCommand(command)

Parameters

NameTypeDescription
commandstring

Returns

boolean

Example

fb.RunMainMenuCommand("File/Add Location...");
method

SavePlaylist

js/foo_uie_jsplitter.js:1312
SavePlaylist()
methodWORKERMAIN THREAD

SetAudioStream

js/foo_uie_jsplitter.js:1333
SetAudioStream(handle, index)

Selects an audio stream for handle and stores it as the user's stream preference.
Available only in foobar2000 v2.0 and above. Throws an Error when API is unavailable, the file does not support stream selection, or index is out of bounds.
If the file is currently playing and the effective selection changes, playback is restarted so the new stream is applied immediately.

Related methods: fb.GetAudioStreams.

Parameters

NameTypeDescription
handleFbMetadbHandle
indexnumber

Zero-based stream index returned by fb.GetAudioStreams.

Throws

Error —

If handle is null, foobar2000 2.0 stream selection is unavailable, the file does not support audio stream selection, or index is out of bounds.

Example

const handle = fb.GetFocusItem();
if (handle) {
    const streams = fb.GetAudioStreams(handle);
    if (streams.length > 1) {
        fb.SetAudioStream(handle, streams[1].index);
    }
}
methodWORKERMAIN THREAD

SetDSPPreset

js/foo_uie_jsplitter.js:1315
SetDSPPreset(idx)

Available only in foobar2000 v1.4 and above. Throws a script error on v1.3.

Related methods: fb.GetDSPPresets.

Parameters

NameTypeDescription
idxnumber

Throws

Error —

If idx is out of bounds.

Example

let str = fb.GetDSPPresets();
let arr = JSON.parse(str);
let idx; // find the required DSP from `arr` and assign it to `idx`
fb.SetDSPPreset(idx);
methodWORKERMAIN THREAD

SetOutputDevice

js/foo_uie_jsplitter.js:1356
SetOutputDevice(output, device)

Available only in foobar2000 v1.4 and above. Throws a script error on v1.3.

Related methods: fb.GetOutputDevices.

Parameters

NameTypeDescription
outputstring
devicestring

Example

// To actually change device, you'll need the device_id and output_id
// and use them with fb.SetOutputDevice.
let str = fb.GetOutputDevices();
let arr = JSON.parse(str);
// Assuming same list from above, switch output to the last device.
fb.SetOutputDevice(arr[4].output_id, arr[4].device_id);
methodWORKERMAIN THREAD

ShowConsole

js/foo_uie_jsplitter.js:1376
ShowConsole(show)

Shows foobar2000 console window or close it (if show=false).

Parameters

NameTypeDescription
show = trueoptionalboolean
methodWORKERMAIN THREAD

ShowLibrarySearchUI

js/foo_uie_jsplitter.js:1385
ShowLibrarySearchUI(query)

Opens the Library>Search window populated with the query you set.

Parameters

NameTypeDescription
querystring
methodWORKERMAIN THREAD

ShowPictureViewer

js/foo_uie_jsplitter.js:1394
ShowPictureViewer(image_path_or_handle, art_id)

Opens the image viewer built in to foobar2000. Pass an image file path, or an FbMetadbHandle; with a handle, AlbumArtId defaults to AlbumArtId.front. Album art is resolved by foobar2000 and may be embedded or external.

Relative filesystem paths are resolved as described in utils.ReadTextFile. This applies to the image-file argument; track handles use foobar2000 artwork lookup.

Parameters

NameTypeDescription
image_path_or_handle(string|FbMetadbHandle)

Image file path or track handle.

art_id = AlbumArtId.frontoptionalAlbumArtId

Album art type. Used only when the first argument is an FbMetadbHandle.

Throws

Error —

If the track handle is invalid, the foobar2000 image viewer API is unavailable, or an image file path cannot be read.

methodWORKERMAIN THREAD

ShowPlaylistSearchUI

js/foo_uie_jsplitter.js:1407
ShowPlaylistSearchUI()

Opens the "Playlist Search" window

methodWORKERMAIN THREAD

ShowPopupMessage

js/foo_uie_jsplitter.js:1414
ShowPopupMessage(message, title)

Parameters

NameTypeDescription
messagestring
title = 'JSplitter'optionalstring
methodWORKERMAIN THREAD

ShowPreferences

js/foo_uie_jsplitter.js:1422
ShowPreferences()
methodWORKERMAIN THREAD

Stop

js/foo_uie_jsplitter.js:1429
Stop()
methodWORKER

TitleFormat

js/foo_uie_jsplitter.js:1436
TitleFormat(expression)

Performance note: if you use the same query frequently, try caching FbTitleFormat object (by storing it somewhere), instead of creating it every time.

Parameters

NameTypeDescription
expressionstring

Returns

FbTitleFormat
methodWORKERMAIN THREAD

UnregisterMainMenuCommand

js/foo_uie_jsplitter.js:1447
UnregisterMainMenuCommand(id, name, description)

Unregisters a main menu item.

Related methods: fb.RegisterMainMenuCommand

Parameters

NameTypeDescription
idnumber

Throws

Error —

If the panel host is not fully initialized or id is not a registered dynamic main-menu command.

methodWORKERMAIN THREAD

VolumeDown

js/foo_uie_jsplitter.js:1459
VolumeDown()
methodWORKERMAIN THREAD

VolumeMute

js/foo_uie_jsplitter.js:1466
VolumeMute()
methodWORKERMAIN THREAD

VolumeUp

js/foo_uie_jsplitter.js:1473
VolumeUp()