on_always_on_top_changed
on_always_on_top_changed(state)
Called when "Always On Top" state changes: from using the menu, Alt + A, fb.AlwaysOnTop and etc.
Parameters
| Name | Type | Description |
|---|---|---|
state | boolean |
on_button_click
on_button_click(id)
Parameters
| Name | Type | Description |
|---|---|---|
id | number | of button created with window.CreateButton and accessed by ButtonObject.ID property. |
on_char
on_char(code)
Note: in order to use this callback, use window.DlgCode(DLGC_WANTCHARS).
See DLGC_WANTCHARS
Parameters
| Name | Type | Description |
|---|---|---|
code | number | UTF16 encoded char |
on_colours_changed
on_colours_changed()
Called when colours are changed via default UI/columns UI preferences.
Note: use window.GetColourCUI / window.GetColourDUI to get new colours.
on_console_refresh
on_console_refresh()
Called when new records are appended to foobar2000 console log.
Note: Can used with console.GetLines or console.ClearBacklog
CAUTION: Don't call console.log in this callback
on_cursor_follow_playback_changed
on_cursor_follow_playback_changed(state)
Called when "cursor follow playback" state is changed.
Parameters
| Name | Type | Description |
|---|---|---|
state | boolean | current "cursor follow playback" value |
on_download_file_done
on_download_file_done(path, success, error_text)
Called when utils.DownloadFileAsync thread is finished
Parameters
| Name | Type | Description |
|---|---|---|
path | string | of downloaded file |
success | boolean | |
error_text | string |
on_drag_drop
on_drag_drop(action, x, y, mask)
See fb.DoDragDrop documentation and
Parameters
| Name | Type | Description |
|---|---|---|
action | DropTargetAction | |
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
Example source
on_drag_enter
on_drag_enter(action, x, y, mask)
See fb.DoDragDrop documentation and
Parameters
| Name | Type | Description |
|---|---|---|
action | DropTargetAction | |
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
Example source
on_drag_leave
on_drag_leave()
See fb.DoDragDrop documentation and
Example source
on_drag_over
on_drag_over(action, x, y, mask)
See fb.DoDragDrop documentation and
Parameters
| Name | Type | Description |
|---|---|---|
action | DropTargetAction | |
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
Example source
on_dsp_preset_changed
on_dsp_preset_changed()
Called when DSP preset changes.
Note: this callback is only available in foobar2000 v1.4 and later.
Note2: does not get called when presets are added or removed.
on_focus
on_focus(is_focused)
Called when the panel gets or loses focus.
Parameters
| Name | Type | Description |
|---|---|---|
is_focused | boolean | New focus state |
on_font_changed
on_font_changed()
Called when fonts are changed via DUI or CUI preferences. Note: you can retrieve fonts using window.GetFontDUI / window.GetFontCUI.
on_get_album_art_done
on_get_album_art_done(handle, art_id, image, image_path)
Called when thread created by utils.GetAlbumArtAsync or utils.GetAlbumArtAsyncV2 is done.
Parameters
| Name | Type | Description |
|---|---|---|
handle | FbMetadbHandle | |
art_id | number | See AlbumArtId flags |
image | ?GdiBitmap | (or D2DBitmap if window.DrawMode == 1). Null on failure |
image_path | string | path to image file (or music file if image is embedded) |
on_http_request_done
on_http_request_done(task_id, success, response_text, status, response_headers)
Called when utils.HTTPRequestAsync request is finished
Parameters
| Name | Type | Description |
|---|---|---|
task_id | number | task id returned by utils.HTTPRequestAsync |
success | boolean | |
response_text | string | |
status | number | HTTP response code |
response_headers | string | stringified JSON containing response headers |
on_item_focus_change
on_item_focus_change(playlistIndex, from, to)
Called when focused item in playlist has been changed.
Parameters
| Name | Type | Description |
|---|---|---|
playlistIndex | number | |
from | number | index of the previous focused item or -1 if there was no focused item. |
to | number | index of the new focued item |
on_item_played
on_item_played(handle)
Called when at least one minute of the track has been played or the track has reached its end after at least 1/3 of it has been played through.
Parameters
| Name | Type | Description |
|---|---|---|
handle | FbMetadbHandle |
on_key_down
on_key_down(vkey)
Requires "Grab focus" enabled in the Configuration window.
In order to use arrow keys, use window.DlgCode(DLGC_WANTARROWS) (see DLGC_WANTARROWS).
Note: keyboard shortcuts defined in the main preferences are always executed first and are not passed to the callback.
Parameters
| Name | Type | Description |
|---|---|---|
vkey | number | Virtual Key Code (for example VK_LEFT), refer to http://msdn.microsoft.com/en-us/library/ms927178.aspx |
on_key_up
on_key_up(vkey)
Requires "Grab focus" enabled in the Configuration window.
In order to use arrow keys, use window.DlgCode(DLGC_WANTARROWS) (see DLGC_WANTARROWS).
Parameters
| Name | Type | Description |
|---|---|---|
vkey | number | Virtual Key Code (for example VK_LEFT), refer to http://msdn.microsoft.com/en-us/library/ms927178.aspx |
on_library_items_added
on_library_items_added(handle_list)
Parameters
| Name | Type | Description |
|---|---|---|
handle_list | FbMetadbHandleList |
on_library_items_changed
on_library_items_changed(handle_list)
Parameters
| Name | Type | Description |
|---|---|---|
handle_list | FbMetadbHandleList |
on_library_items_removed
on_library_items_removed(handle_list)
Parameters
| Name | Type | Description |
|---|---|---|
handle_list | FbMetadbHandleList |
on_load_image_done
on_load_image_done(cookie, image, image_path)
Called when thread created by gdi.LoadImageAsync is done.
Parameters
| Name | Type | Description |
|---|---|---|
cookie | number | the return value from the gdi.LoadImageAsync call |
image | ?GdiBitmap | (or D2DBitmap if window.DrawMode == 1). Null on failure (invalid path/not an image) |
image_path | string | the path that was originally supplied to gdi.LoadImageAsync |
on_locations_added
on_locations_added(task_id, handles)
Called when fb.AddLocationsAsync thread is finished
Parameters
| Name | Type | Description |
|---|---|---|
task_id | number | |
handles | FbMetadbHandleList |
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);
}
on_main_menu
on_main_menu(index)
On the main menu>File>Spider Monkey Panel, there are 10 menu items and whichever number is selected is sent as the "index" to this callback.
Being main menu items now means you can bind them to global keyboard shortcuts, standard toolbar buttons, panel stack splitter buttons, etc.
Remember to think carefully about where you use this code as you probably only want it to run once and so don't include it in common files and scripts where you might have multiple instances.
Important: you should avoid sharing scripts containing this code so as not to conflict with what other users may already be using.
Deprecated: use on_main_menu_dynamic instead.
Parameters
| Name | Type | Description |
|---|---|---|
index | number |
Example
function on_main_menu(index) {
switch (index) {
case 1: // triggered when File>Spider Monkey Panel>1 is run
do_something();
break;
case 2: // triggered when File>Spider Monkey Panel>2 is run
do_something_else();
break;
}
}
on_main_menu_dynamic
on_main_menu_dynamic(command_id)
Called when one of the commands corresponding to this panel from main menu>File>Spider Monkey Panel>Script commands is executed.
Related methods: fb.RegisterMainMenuCommand, fb.UnregisterMainMenuCommand
Parameters
| Name | Type | Description |
|---|---|---|
command_id | number | Id of the associated command |
on_metadb_changed
on_metadb_changed(handle_list, fromhook)
Called when metadb contents change.
Parameters
| Name | Type | Description |
|---|---|---|
handle_list | FbMetadbHandleList | affected items |
fromhook | boolean | true if notification is not from tag update, but a component that provides tag-like data from a database. E.g. foo_playcount and FbMetadbHandle.RefreshStats |
on_mouse_lbtn_dblclk
on_mouse_lbtn_dblclk(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_lbtn_down
on_mouse_lbtn_down(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_lbtn_up
on_mouse_lbtn_up(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_leave
on_mouse_leave()
on_mouse_mbtn_dblclk
on_mouse_mbtn_dblclk(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_mbtn_down
on_mouse_mbtn_down(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_mbtn_up
on_mouse_mbtn_up(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_move
on_mouse_move(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_rbtn_dblclk
on_mouse_rbtn_dblclk(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_rbtn_down
on_mouse_rbtn_down(x, y, mask)
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_mouse_rbtn_up
on_mouse_rbtn_up(x, y, mask)
You must return true, if you want to suppress the default context menu.
Note: left shift + left windows key will bypass this callback and will open default context menu.
Parameters
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
Returns
booleanon_mouse_wheel
on_mouse_wheel(step)
Scroll up/down
Parameters
| Name | Type | Description |
|---|---|---|
step | number | scroll direction: -1 or 1 |
on_mouse_wheel_h
on_mouse_wheel_h(step)
Scroll left/right
Parameters
| Name | Type | Description |
|---|---|---|
step | number | scroll direction: -1 or 1 |
on_notify_data
on_notify_data(name, info)
Called in other panels after window.NotifyOthers is executed.
!!! Beware !!!
1. Data from info argument is only accessible inside on_notify_data callback: if stored and accessed outside of the callback it will throw JS error.
This also applies to the data produced from that info: e.g. storing info.Path directly (if info is FbMetadbHandle).
2. If you want to store the data from info you have to perform a deep copy:
- String(info) for strings.
- JSON.parse(JSON.stringify(info)) for serializable objects.
- new ObjectType(info) for objects that have an approppriate constructor available, e.g. new GdiBitmap(info) or new FbMetadbHandleList(info).
3. info argument is shared between panels, so it should NOT be modified in any way.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | |
info | * |
on_output_device_changed
on_output_device_changed()
Called when output device changes. Use fb.GetOutputDevices to retrieve settings.
Note: available only in foobar2000 v1.4 and later.
on_paint
on_paint(gr)
Called when window is ready to draw.
Parameters
| Name | Type | Description |
|---|---|---|
gr | GdiGraphics |
on_panel_mouse_enter
on_panel_mouse_enter(name)
Raises when mouse pointer entering JSplitter child panel area
Works only if window.TrackMouseEnterLeaveOnPanels is true
Parameters
| Name | Type | Description |
|---|---|---|
name | string | of panel mouse pointer enters |
on_panel_mouse_leave
on_panel_mouse_leave(name)
Raises when mouse pointer leaving JSplitter child panel area
Works only if window.TrackMouseEnterLeaveOnPanels is true
Parameters
| Name | Type | Description |
|---|---|---|
name | string | of panel mouse pointer leaves |
on_panel_mouse_move
on_panel_mouse_move(name, x, y, mask)
Raises when mouse pointer moving over JSplitter child panel area
Works only if window.TrackMouseMoveOnPanels is true
Parameters
| Name | Type | Description |
|---|---|---|
name | string | of panel mouse pointer moves over |
x | number | |
y | number | |
mask | number | Mask for mouse callbacks, see flags like MK_LBUTTON |
on_playback_dynamic_info
on_playback_dynamic_info()
Called when dynamic info (VBR bitrate etc) changes.
on_playback_dynamic_info_track
on_playback_dynamic_info_track()
Called when Per-track dynamic info (stream track titles etc) changes.
Happens less often than on_playback_dynamic_info.
on_playback_edited
on_playback_edited(handle)
Called when currently playing file gets edited.
It's also called by components that provide tag-like data such as foo_playcount.
Parameters
| Name | Type | Description |
|---|---|---|
handle | FbMetadbHandle |
on_playback_follow_cursor_changed
on_playback_follow_cursor_changed(state)
Called when "playback follow cursor" state is changed.
Parameters
| Name | Type | Description |
|---|---|---|
state | boolean | current "playback follow cursor" value |
on_playback_new_track
on_playback_new_track(handle)
Playback advanced to the new track.
Parameters
| Name | Type | Description |
|---|---|---|
handle | FbMetadbHandle |
on_playback_order_changed
on_playback_order_changed(new_order_index)
Called when playback order is changed.
Parameters
| Name | Type | Description |
|---|---|---|
new_order_index | any | see PlaybackOrder enum |
on_playback_pauseQueueChangeType
on_playback_pauseQueueChangeType(state)
Parameters
| Name | Type | Description |
|---|---|---|
state | boolean | true when paused, false when unpaused. |
on_playback_queue_changed
on_playback_queue_changed(origin)
Parameters
| Name | Type | Description |
|---|---|---|
origin | number | see QueueChangeOrigin enum |
on_playback_seek
on_playback_seek(time)
Parameters
| Name | Type | Description |
|---|---|---|
time | float | new position in seconds |
on_playback_starting
on_playback_starting(cmd, is_paused)
Playback process is being initialized.
on_playback_new_track should be called soon after this when first file is successfully opened for decoding.
Parameters
| Name | Type | Description |
|---|---|---|
cmd | number | see PlaybackStartCmd enum |
is_paused | boolean | Current paused state |
on_playback_stop
on_playback_stop(reason)
Parameters
| Name | Type | Description |
|---|---|---|
reason | number | see PlaybackStopReason enum |
on_playback_time
on_playback_time(time)
Called every second, for time display.
Parameters
| Name | Type | Description |
|---|---|---|
time | float | current playback time in seconds |
on_playlist_item_ensure_visible
on_playlist_item_ensure_visible(playlistIndex, playlistItemIndex)
Parameters
| Name | Type | Description |
|---|---|---|
playlistIndex | number | |
playlistItemIndex | number |
on_playlist_items_added
on_playlist_items_added(playlistIndex)
Parameters
| Name | Type | Description |
|---|---|---|
playlistIndex | number |
on_playlist_items_removed
on_playlist_items_removed(playlistIndex, new_count)
Parameters
| Name | Type | Description |
|---|---|---|
playlistIndex | number | |
new_count | number |
on_playlist_items_reordered
on_playlist_items_reordered(playlistIndex)
Changes selection too. Doesn't actually change the set of items that are selected or item having focus, just changes their order.
Parameters
| Name | Type | Description |
|---|---|---|
playlistIndex | number |
on_playlist_items_selection_change
on_playlist_items_selection_change()
Workaround for some 3rd party playlist viewers not working with on_selection_changed.
on_playlist_stop_after_current_changed(state)
Called when "stop after current" is enabled/disabled.
Parameters
| Name | Type | Description |
|---|---|---|
state | boolean | "stop after current" value |
on_playlist_switch
on_playlist_switch()
on_playlists_changed
on_playlists_changed()
Called when:
- Playlists are added/removed/reordered/renamed.
- A playlist's lock status changes through the use of plman.SetPlaylistLockedActions or components such as foo_utils or foo_playlist_attributes.
on_replaygain_mode_changed
on_replaygain_mode_changed(new_mode)
Note: available only in foobar2000 v1.4 and later.
Parameters
| Name | Type | Description |
|---|---|---|
new_mode | number | see ReplayGainMode enum |
on_script_unload
on_script_unload()
Called when:
- Panel script is reloaded via context menu > Reload.
- Panel script is changed via panel menu > Configure.
- fb2k is exiting normally.
Not called when:
- Script fails with error.
- fb2k closed externally (e.g. killed with process manager).
- fb2k fails with exception.
on_selection_changed
on_selection_changed()
Called when selection changes based on "File>Preferences>Display>Selection viewers".
on_size
on_size(width, height)
Called when panel is resized.
Note: width and height arguments have the same values as window.Width and window.Height.
IMPORTANT: do NOT call window.Repaint from this callback!
Parameters
| Name | Type | Description |
|---|---|---|
width | number | |
height | number |
on_volume_change
on_volume_change(val)
Parameters
| Name | Type | Description |
|---|---|---|
val | float | volume level in dB. Minimum is -100. Maximum is 0. |
PerformanceObserverCallback
PerformanceObserverCallback(entries, observer)
Callback that will be invoked when observed performance events are recorded. Specified in PerformanceObserver constructor
Parameters
| Name | Type | Description |
|---|---|---|
entries | PerformanceObserverEntryList | The list of performance observer entries. |
observer | PerformanceObserver | The observer object that is receiving the above entries. |