Documentation/FbMetadbHandleList
FbMetadbHandleList(arg)
Handle list elements can be accessed with array accessor, e.g. handle_list[i]
Count: number
Example
let handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
console.log(handle_list.Count);
Add(handle)
Example
handle_list.Add(fb.GetNowPlaying());
AddRange(handle_list)
Example
handle_list.AddRange(fb.GetLibraryItems());
AttachImage(image_path, art_id)
Embeds covers of the specified type, loaded from the specified file, into media files
Any existing artwork of the specified type will be overwritten!
Embedding covers is an asynchronous operation, so its result is not controlled here in any way. However, all the work of the method up to this point (reading file, creating art data) will return false in case of an error.
Parameters
| Name | Type | Description |
image_path | string | path to an existing image |
art_id = AlbumArtId.frontoptional | AlbumArtId | See AlbumArtId |
Returns
boolean —
Returns false if any error occurred before the embedding started, otherwise true
Examples
include(`${fb.ComponentPath}docs\\Flags.js`);
const handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
if (handle_list.Count > 0) {
const img_path = 'C:\\path\\to\\image.jpg';
handle_list.AttachImage(img_path, AlbumArtId.front);
}
include(`${fb.ComponentPath}docs\\Flags.js`);
const handle_list = new FbMetadbHandleList(fb.GetFocusItem());
const img_path = "C:\\path\\to\\image.jpg";
handle_list.AttachImage(img_path, AlbumArtId.front);
AttachImage2(image, art_id, codec, quality)
Embeds covers of the specified type from exisiting GdiBitmap or D2DBitmap object. Supports JPEG, WEBP and PNG codecs for encoding image before embedding.
Any existing artwork of the specified type will be overwritten!
Embedding covers is an asynchronous operation, so its result is not controlled here in any way. However, all the work of the method up to this point (encoding, creating art data) will return false in case of an error.
Returns
boolean —
Returns false if any error occurred before the embedding started, otherwise true
Examples
include(`${fb.ComponentPath}docs\\Flags.js`);
const handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
if (handle_list.Count > 0) {
const img = gdi.Image("C:\\path\\to\\image.jpg");
handle_list.AttachImage2(img, AlbumArtId.front, AttachImage2Codec.WebP, 60);
}
* include(`${fb.ComponentPath}docs\\Flags.js`);
const handle_list = new FbMetadbHandleList(fb.GetFocusItem());
const img = gdi.Image("C:\\path\\to\\image.jpg");
handle_list.AttachImage2(img, AlbumArtId.front, AttachImage2Codec.WebP, 60);
BSearch(handle)
CalcTotalDuration()
CalcTotalSize()
Returns
number —
total size in bytes. For display purposes, consider using utils.FormatFileSize() on the result.
Clone()
Example
let handle_list2 = handle_list.Clone();
Convert()
Example
let playlist_items_array = plman.GetPlaylistItems(plman.ActivePlaylist).Convert();
for (let i = 0; i < playlist_items_array.length; ++i) {
}
Find(handle)
Performance note: if sorted with Sort, use BSearch instead.
Returns
number —
index in the handle list on success, -1 if not found
GetLibraryRelativePaths()
See fb.GetLibraryRelativePath.
This should be faster than looping a handle list manually and using the aforementioned method.
Example
let handle_list = fb.GetLibraryItems();
handle_list.OrderByRelativePath();
let relative_paths = handle_list.GetLibraryRelativePaths();
GetOtherInfo()
Provides all the information viewable on the Details tab in the main Properties dialog. This can be technical/location info as well as database fields from 3rd party components if present.
This returns a JSON object in string form so you need to use JSON.parse on the result.
Example
const handle_list = plman.GetPlaylistItems(plman.ActivePlaylist);
const str = handle_list.GetOtherInfo();
console.log(str);
Insert(index, handle)
Example
handle_list.Insert(handle_list.Count, fb.GetNowPlaying());
InsertRange(index, handle_list)
MakeDifference(handle_list)
Example
let one = plman.GetPlaylistItems(0);
one.Sort();
let two = plman.GetPlaylistItems(1);
two.Sort();
one.MakeDifference(two);
MakeIntersection(handle_list)
Note: sort with Sort before using.
Example
let one = plman.GetPlaylistItems(0);
one.Sort();
let two = plman.GetPlaylistItems(1);
two.Sort();
one.MakeIntersection(two);
MakeUnion(handle_list)
Note: sort with Sort before using.
Example
let one = plman.GetPlaylistItems(0);
one.Sort();
let two = plman.GetPlaylistItems(1);
two.Sort();
one.MakeUnion(two);
OptimiseFileLayout(minimise)
Parameters
| Name | Type | Description |
minimise | boolean | This provides the same functionality as the native context menu items under Utilities except there are no prompts. |
OrderByFormat(tfo, direction)
Parameters
| Name | Type | Description |
tfo | FbTitleFormat | An instance of FbTitleFormat. |
direction | number | > 0 - ascending. |
Example
let handle_list = fb.GetLibraryItems();
let tfo = fb.TitleFormat("%album artist%|%date%|%album%|%discnumber%|%tracknumber%");
handle_list.OrderByFormat(tfo, 1);
OrderByPath()
Note: this method should only be used on a handle list containing items that are monitored as part of the Media Library.
OrderByRelativePath()
RefreshStats()
Remove(handle)
RemoveAll()
RemoveAttachedImage(art_id)
Note: a progress dialog will be shown for larger file selections.
Parameters
| Name | Type | Description |
art_id = 0optional | number | See AlbumArtId |
RemoveAttachedImages()
Removes all attached images.
Note: a progress dialog will be shown for larger file selections.
RemoveById(idx)
Parameters
| Name | Type | Description |
idx | number | |
Example
handle_list.RemoveById(0);
RemoveRange(from, num)
Parameters
| Name | Type | Description |
from | number | |
num | number | |
Example
handle_list.RemoveRange(10, 20);
SaveAs(path)
Parameters
| Name | Type | Description |
path | string | |
Sort()
Remove duplicates and optimise for other handle list operations
UpdateFileInfoFromJSON(str)
Updated metadb tags with new values.
Parameters
| Name | Type | Description |
str | string | JSON string, which contains an object (applies same values to every track) or an array of objects (one object per track). |
Example
let handles = plman.GetPlaylistSelectedItems(plman.ActivePlaylist);
let arr = [];
for (let i = 0; i < handles.Count; ++i) {
arr.push({
'tracknumber' : i + 1,
'totaltracks' : handles.Count,
'album' : 'Greatest Hits',
'genre' : ['Rock', 'Hard Rock'],
'bad_tag' : ''
});
}
handles.UpdateFileInfoFromJSON(JSON.stringify(arr));