PlaylistEntries Class
Entries in playlists or the Playing list. Use getTracklist() to "convert" it into a tracklist.
Item Index
Methods
- add
- addList
- anyChecked
- asyncFill
- autoUpdatesSuspended
- beginUpdate
- checkUpdate
- clear
- clearSelection
- copySelectionAsync
- delete
- deleteSelected
- endUpdate
- filterByInfix
- filterByPrefix
- filterBySearchPhrase
- filterByWordPrefix
- firstSelected
- forEach
- getAllChecked
- getAllValues
- getCheckedList
- getClassName
- getCopy
- getCopyPreserveFlags
- getEmptyList
- getFastObject
- getRange
- getSelectedList
- getTracklist
- getValue
- getValueLink
- hasAllSelected
- hasItemsSelected
- hasSameItems
- indexOf
- indexOfPersistentIDAsync
- insert
- insertList
- isChecked
- isSelected
- locked
- merge
- modifyAsync
- moveSelectionTo
- notifyChanged
- notifyLoaded
- remove
- removeAsync
- resumeAutoUpdates
- selectRange
- selectRangeAsync
- setAllChecked
- setChecked
- setSelected
- setSortRule
- setValue
- suspendAutoUpdates
- useList
- whenLoaded
Properties
Methods
add
(
Integer
-
data
Add new item to the list.
Parameters:
-
data
ObjectObject to be added in list
Returns:
Integer:
anyChecked
()
Boolean
Return true when any item is checked
Returns:
Boolean:
asyncFill
(
Promise
-
total
-
callback
Asynchronous copy of JS objects to list items. As example check musicBrainz script.
Parameters:
-
total
Integercount of items to fill -
callback
Methodto fill one item (with parameters: int, item)
Returns:
autoUpdatesSuspended
()
Boolean
Return status of the updates. True when auto-updates are suspended by suspendUpdates method.
Returns:
Boolean:
beginUpdate
()
Lock object to update state. Events are not called when in update state.
checkUpdate
()
Updates the object every X ms when called periodically. Useful e.g. when filling lists.
Can be used only in the update lock! (i.e. between beginUpdate/endUpdate)
clear
()
Clear list (remove all items).
clearSelection
()
Clears selection.
copySelectionAsync
(
Promise
-
fromList
Copies selection from one list to another. Returns a promise which is fulfilled with the index of the first selected item when it's all done.
Parameters:
-
fromList
SharedListSource list to copy selection from.
Returns:
delete
(
-
index
Delete item at specified index.
Parameters:
-
index
IntegerIndex of a item to be removed
deleteSelected
()
Removes selected items from the list
endUpdate
()
Unlock object from update state. {{#crossLink "SharedObservable/beginUpdate"}}beginUpdate{{/crossLink}} and endUpdate must be in pair.
When endUpdate is called, {{#crossLink "SharedObservable/onChange"}}{{/crossLink}} event is called.
filterByInfix
(
List
-
value
Returns list with items including the string value.
Space is used as OR operator (if not in quotes)
Parameters:
-
value
StringInfix to check
Returns:
List:
filterByPrefix
(
List
-
value
Returns list with items starting with specified string value.
Space is used as OR operator (if not in quotes)
Parameters:
-
value
StringPrefix to check
Returns:
List:
filterBySearchPhrase
(
List
-
value
Returns list with items matching the specified search phrase (according to Options -> Search conf.).
Parameters:
-
value
StringPhrase to search
Returns:
List:
filterByWordPrefix
(
List
-
value
Returns list with items starting with specified string value (within any word).
Space is used as OR operator (if not in quotes)
Parameters:
-
value
StringWord prefix to check
Returns:
List:
firstSelected
()
SharedObject
Returns first selected item (if any item is selected).
Added in 5.0.4
Returns:
forEach
(
-
callback
Browse all items and send them one by one in defined callback. Note that the items for the callback method are prepared using
{{#crossLink "SharedList/getFastAccess"}}{{/crossLink}}, i.e. the performance is good, but you should only use them in the callback method and don't preserve them for later use.
Parameters:
-
callback
MethodCallback to be called with each item
Example:
list.forEach(function(item) {
// Process the item
})
getAllChecked
()
Boolean
Return true when all items are checked
Returns:
Boolean:
getAllValues
(
Array
-
key
Gets an array of all values of the specified property key. This is faster than getFastObject if you need to retrieve only one or two property values (instead of the entire object). [ADDED IN VERSION 5.0.2]
Parameters:
-
key
StringProperty to retrieve from each item (if empty then item is added as string)
Returns:
Array:
getClassName
()
String
Gets class name of the object.
Returns:
String:
getFastObject
(
Object
-
index
-
object
Gets fast access to item at specified index. Note that this call always returns the same JS object, just modifies the internals so that properties/methods work on different data.
It means, that you shouldn't preserve this object for later use, because it would be modified and the result would be unexpected.
Parameters:
-
index
IntegerIndex of the item -
object
ObjectObject to pass
Returns:
Object:
getRange
(
SharedList
-
fromIndex
-
toIndex
Gets copy of the list with specified range indexes.
Parameters:
-
fromIndex
IntegerStarting index -
toIndex
IntegerEnding index
Returns:
getValue
(
Object
-
index
Gets object from specified index. List needs to be locked before use (see {{#crossLink "SharedBase/locked"}}{{/crossLink}}).
Parameters:
-
index
IntegerIndex of item
Returns:
Object:
getValueLink
(
Object
-
index
Gets link to a object from specified index. List needs to be locked before use (see {{#crossLink "SharedBase/locked"}}{{/crossLink}}).
Parameters:
-
index
IntegerIndex of item
Returns:
Object:
hasAllSelected
()
Boolean
Returns true, if all is selected in the list.
Returns:
Boolean:
hasItemsSelected
()
Boolean
Returns true, if something is selected in the list.
Returns:
Boolean:
hasSameItems
(
Boolean
-
list
Compares two lists for the same content
Parameters:
-
list
SharedListList to be compared
Returns:
Boolean:
indexOf
(
Integer
-
data
Gets index of a item in list.
Parameters:
-
data
ObjectObject to be found
Returns:
Integer:
indexOfPersistentIDAsync
(
Promise
-
persistent
Get position of the item identified by persistent ID.
Parameters:
-
persistent
StringID of item to locate
Returns:
insert
(
Integer
-
position
-
data
Inserts a new item to a specified position in the list.
Parameters:
-
position
IntegerThe desired position in the list -
data
ObjectObject to be added in list
Returns:
Integer:
insertList
(
-
index
-
list
Inserts list of items to the list at specified position.
Parameters:
-
index
IntegerPosition -
list
SharedListList to be added
isChecked
(
Boolean
-
index
Gets item at specified index is checked.
Parameters:
-
index
IntegerIndex of the item
Returns:
Boolean:
isSelected
(
Boolean
-
index
Gets item at specified index is selected.
Parameters:
-
index
IntegerIndex of the item
Returns:
Boolean:
locked
(
-
func
Call defined method with locked data so user can access them.
Parameters:
-
func
MethodMethod to call
merge
(
SharedList
-
list
-
merge
Merges this list with list in parameter and returns new merged list
Parameters:
-
list
SharedListto merge -
merge
Stringmethod ('join' - input list is appended to this list, 'oddeven' - items are mixed, odds are from this list, evens are from the input list)
Returns:
SharedList:
new merged list
modifyAsync
(
Promise
-
func
Call defined method with the list locked for modifications. It tries to perform the callback immediatelly, but in case there's already a write lock on the list,
it performs the callback later.
Parameters:
-
func
MethodMethod to call
Returns:
moveSelectionTo
(
-
newIndex
Move selected items to new position.
Parameters:
-
newIndex
IntegerNew index where to move selected items
notifyChanged
()
Notifies that the object was changed (e.g. to force visual update etc.)
notifyLoaded
()
Notifies list was loaded and whenLoaded promise can be fulfilled.
remove
(
Integer
-
data
Delete item from list.
Parameters:
-
data
ObjectObject to be removed from list
Returns:
Integer:
removeAsync
(
Promise
-
data
Delete item from list asynchronously.
Parameters:
-
data
ObjectObject to be removed from list
Returns:
resumeAutoUpdates
()
Boolean
Resume auto updates and run auto update immediatelly when any update is pending.
Returns:
Boolean:
selectRange
(
-
fromIndex
-
toIndex
-
select
Select items in range.
Parameters:
-
fromIndex
IntegerStart index -
toIndex
IntegerEnd index -
select
BooleanWhether to select or unselect
selectRangeAsync
(
Promise
-
fromIndex
-
toIndex
-
[select]
-
[clearSelection]
Select items in range, asynchronously.
Parameters:
-
fromIndex
IntegerStart index -
toIndex
IntegerEnd index -
[select]
Boolean optionalWhether to select or unselect -
[clearSelection]
Boolean optionalWhether to clear selection of the whole list before the operation
Returns:
setAllChecked
(
-
state
Set all items to (un)checked state
Parameters:
-
state
BooleanCheck state
setChecked
(
-
index
-
value
Sets checked flag to item in specified index.
Parameters:
-
index
IntegerIndex of the item -
value
BooleanTrue when checked
setSelected
(
-
index
-
value
Sets selected flag to item in specified index.
Parameters:
-
index
IntegerIndex of the item -
value
BooleanTrue when selected
setSortRule
(
Boolean
-
rule
SYNCHRONOUSLY sorts the list with the given sorting rule and disables auto-sort.
To specify sort direction, append ' ASC' or ' DESC' to the tag name and separate them by semicolons.
Fields are NOT case sensitive (e.g. 'artist', 'Artist', and 'ArTiSt') are all valid, but sort direction IS case sensitive ('ASC' and 'DESC' are valid; 'asc' and 'desc' are not)
Valid examples:
list.setSortRule('title');
list.setSortRule('artist; title');
list.setSortRule('rating DESC; title ASC');
list.setSortRule('Rating DESC; TITLE;');
Invalid examples:
list.setSortRule('tagThatDoesNotExist');
list.setSortRule('rating desc; title asc');
Parameters:
-
rule
StringSemicolon separated list of sorting rules.
Returns:
Boolean:
setValue
(
-
index
-
value
Sets object at specified index in the list. List needs to be locked before use (see {{#crossLink "SharedBase/locked"}}{{/crossLink}}).
Parameters:
-
index
IntegerIndex where to be added -
value
ObjectObject to be added
suspendAutoUpdates
()
Suspend auto updates.
useList
(
-
list
Add list of items to the list, but clears the old values.
i.e. is the same as calling clear+addList
Parameters:
-
list
SharedListList to be used
Properties
asJSON
String
Gets the object as serialized JSON string.
Or sets serialized JSON (to fill this object's metadata by the metadata included within the JSON)
count
Integer
Total count of items in list.
deleted
Boolean
Set to true after deletion so that 'change' event is called and item is removed from UI lists.
focusedIndex
Integer
Index of focused item in the list.
id
Integer
Gets integer id of the object
isObservable
Unknown
Whether this object can be listened (e.g. for 'change' event)
isStatusBarSource
Boolean
Is source for status bar informations.
objectType
String
Gets the object type as string
persistentID
String
Gets persistent id of the object
title
String
Gets the object title
Events
beforeSort
Event is called before list sort begins
change
Event is called when object is somehow changed
Event Payload:
-
changeType
Stringadditional change type (can have values like 'tracklist', 'deleted', 'title' or undefined)
Example:
app.listen(object, 'change', (changeType) => { });
destroying
Event is called when object is going to destroy
focuschange
Event is called when focused item is changted
Event Payload:
-
new
Integerfocused item index -
old
Integerfocused index
loaded
Event is called when list is notified as loaded
sorted
Event is called when list sort is finished
statuschange
Event is called when status info of the object is changed