API Docs for: 5.0.3
Show:

PlaylistEntries Class

Extends SharedList
Module: Native

Entries in playlists or the Playing list. Use getTracklist() to "convert" it into a tracklist.

Methods

add

(
  • data
)
Integer
Add new item to the list.

Parameters:

  • data Object
    Object to be added in list

Returns:

Integer:

addList

(
  • list
)

Inherited from SharedList but overwritten in native\BaseShared.js:1317

Add list of items to the list.

Parameters:

anyChecked

() Boolean
Return true when any item is checked

Returns:

Boolean:

asyncFill

(
  • total
  • callback
)
Promise
Asynchronous copy of JS objects to list items. As example check musicBrainz script.

Parameters:

  • total Integer
    count of items to fill
  • callback Method
    to 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

(
  • fromList
)
Promise
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 SharedList
    Source list to copy selection from.

Returns:

delete

(
  • index
)
Delete item at specified index.

Parameters:

  • index Integer
    Index 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

(
  • value
)
List
Returns list with items including the string value. Space is used as OR operator (if not in quotes)

Parameters:

  • value String
    Infix to check

Returns:

List:

filterByPrefix

(
  • value
)
List
Returns list with items starting with specified string value. Space is used as OR operator (if not in quotes)

Parameters:

  • value String
    Prefix to check

Returns:

List:

filterBySearchPhrase

(
  • value
)
List
Returns list with items matching the specified search phrase (according to Options -> Search conf.).

Parameters:

  • value String
    Phrase to search

Returns:

List:

filterByWordPrefix

(
  • value
)
List
Returns list with items starting with specified string value (within any word). Space is used as OR operator (if not in quotes)

Parameters:

  • value String
    Word 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 Method
    Callback 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

(
  • key
)
Array
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 String
    Property to retrieve from each item (if empty then item is added as string)

Returns:

Array:

getCheckedList

() SharedList
Returns a list of all checked items.

Returns:

getClassName

() String
Gets class name of the object.

Returns:

String:

getCopy

() SharedList
Gets copy of the list.

Returns:

getCopyPreserveFlags

() SharedList
Gets copy of the list, preserves flags (selection).

Returns:

getEmptyList

() SharedList
Returns empty list.

Returns:

getFastObject

(
  • index
  • object
)
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 Integer
    Index of the item
  • object Object
    Object to pass

Returns:

Object:

getRange

(
  • fromIndex
  • toIndex
)
SharedList
Gets copy of the list with specified range indexes.

Parameters:

  • fromIndex Integer
    Starting index
  • toIndex Integer
    Ending index

Returns:

getSelectedList

() SharedList
Returns a list of all selected items.

Returns:

getTracklist

() Tracklist

Returns a Tracklist equivalent of the PlaylistEntries list.

Returns:

getValue

(
  • index
)
Object
Gets object from specified index. List needs to be locked before use (see {{#crossLink "SharedBase/locked"}}{{/crossLink}}).

Parameters:

  • index Integer
    Index 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

(
  • list
)
Boolean
Compares two lists for the same content

Parameters:

Returns:

Boolean:

indexOf

(
  • data
)
Integer
Gets index of a item in list.

Parameters:

  • data Object
    Object to be found

Returns:

Integer:

indexOfPersistentIDAsync

(
  • persistent
)
Promise
Get position of the item identified by persistent ID.

Parameters:

  • persistent String
    ID of item to locate

Returns:

insert

(
  • position
  • data
)
Integer
Inserts a new item to a specified position in the list.

Parameters:

  • position Integer
    The desired position in the list
  • data Object
    Object to be added in list

Returns:

Integer:

insertList

(
  • index
  • list
)
Inserts list of items to the list at specified position.

Parameters:

  • index Integer
    Position
  • list SharedList
    List to be added

isChecked

(
  • index
)
Boolean
Gets item at specified index is checked.

Parameters:

  • index Integer
    Index of the item

Returns:

Boolean:

isSelected

(
  • index
)
Boolean
Gets item at specified index is selected.

Parameters:

  • index Integer
    Index of the item

Returns:

Boolean:

locked

(
  • func
)
Call defined method with locked data so user can access them.

Parameters:

  • func Method
    Method to call

merge

(
  • list
  • merge
)
SharedList
Merges this list with list in parameter and returns new merged list

Parameters:

  • list SharedList
    to merge
  • merge String
    method ('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

(
  • func
)
Promise

Inherited from SharedObservable but overwritten in native\BaseShared.js:1755

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 Method
    Method to call

Returns:

moveSelectionTo

(
  • newIndex
)
Move selected items to new position.

Parameters:

  • newIndex Integer
    New 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

(
  • data
)
Integer
Delete item from list.

Parameters:

  • data Object
    Object to be removed from list

Returns:

Integer:

removeAsync

(
  • data
)
Promise
Delete item from list asynchronously.

Parameters:

  • data Object
    Object 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 Integer
    Start index
  • toIndex Integer
    End index
  • select Boolean
    Whether to select or unselect

selectRangeAsync

(
  • fromIndex
  • toIndex
  • [select]
  • [clearSelection]
)
Promise
Select items in range, asynchronously.

Parameters:

  • fromIndex Integer
    Start index
  • toIndex Integer
    End index
  • [select] Boolean optional
    Whether to select or unselect
  • [clearSelection] Boolean optional
    Whether to clear selection of the whole list before the operation

Returns:

setAllChecked

(
  • state
)
Set all items to (un)checked state

Parameters:

  • state Boolean
    Check state

setChecked

(
  • index
  • value
)
Sets checked flag to item in specified index.

Parameters:

  • index Integer
    Index of the item
  • value Boolean
    True when checked

setSelected

(
  • index
  • value
)
Sets selected flag to item in specified index.

Parameters:

  • index Integer
    Index of the item
  • value Boolean
    True when selected

setSortRule

(
  • rule
)
Boolean
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 String
    Semicolon 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 Integer
    Index where to be added
  • value Object
    Object 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:

whenLoaded

() Promise
Returns a promise which is called when loading is finished. Loading is finished by calling {{#crossLink "SharedList/notifyLoaded"}}{{/crossLink}} method.

Returns:

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.

focusedItem

SharedObject
Gets 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 String
    additional 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 Integer
    focused item index
  • old Integer
    focused 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