API Docs for: 5.0.3
Show:

Playlist Class

Extends PinableObject
Module: Native

Playlist class

Methods

addTrackAsync

(
  • Track
)

Add track into playlist

Parameters:

addTrackById

(
  • TrackID
)

Add track into playlist

Parameters:

  • TrackID Integer

    Track ID (as is in database, table Songs.ID)

addTracksAsync

(
  • Tracks
)

Add tracks into playlist

Parameters:

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)

clearTracksAsync

()

Clears this playlist's tracks

commitAsync

()

Commits this playlist

createCopyAsync

() Playlist

Creates copy (clone) of this playlist

Returns:

Playlist:

as promise

deleteAsync

()

Deletes this playlist

endUpdate

()

Unlock object from update state. beginUpdate and endUpdate must be in pair. When endUpdate is called, SharedObservable/onChange event is called.

getChildren

()

Gets children playlists (sub-playlists)

getClassName

() String

Gets class name of the object.

Returns:

String:

getLastModifiedAsync

()

Gets playlist last modified timestamp

getTracklist

() Tracklist

Gets tracks of this playlist

Returns:

Tracklist:

as promise

Example:

var trcklist = Playlist.getTracklist();
trcklist.whenLoaded().then(function () {
// all tracks are loaded here
});

insertTrackAsync

(
  • Track
)

Inserts track into playlist

Parameters:

  • Track Track

    Track to insert

insertTracksAsync

(
  • Tracks
)

Inserts tracks into playlist

Parameters:

isPinned

() Promise

Object is pinned in pinned list

Returns:

locked

(
  • func
)

Call defined method with locked data so user can access them.

Parameters:

  • func Method

    Method to call

modifyAsync

(
  • func
)
Promise

Call defined method with the item locked for modifications.

Parameters:

  • func Method

    Method to call

Returns:

moveTrackAsync

(
  • track
  • beforeTrack
)

Moves a track in the playlist

Parameters:

  • track Track

    Track to move from

  • beforeTrack Track

    Moves before this track

newPlaylist

() Playlist

Creates new sub-playlist of this playlist

Returns:

notifyChanged

()

Notifies that the object was changed (e.g. to force visual update etc.)

removeSelectedTracksAsync

(
  • Tracks
)

Removes selected tracks from playlist

Parameters:

  • Tracks Tracklist

    SongList with selected tracks to remove

removeTrackAsync

(
  • Track
)

Removes track from playlist

Parameters:

  • Track Track

    Track to remove

reorderAsync

(
  • Tracks
)

Saves re-ordered playlist's tracks into DB.

Does not function with Auto-Playlists. Auto-Playlists use QueryData for their sorting. See searchEditor.js and playlistHeader.js for an example on how to manipulate QueryData for sorting.

Parameters:

  • Tracks Tracklist

    Re-ordered tracks to commit

setPinned

(
  • pinned
  • collID
)

Set object is pinned in pinned list.

Parameters:

  • pinned Boolean

    Object is pinned

  • collID Integer

    ID of collection where object is pinned

setTracksAsync

(
  • Tracks
)

Add tracks into playlist, but clears the existing tracks at first.
NOTE: Introduced in version 5.0.4

Parameters:

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)

childrenCount

Integer

Gets count of child playlists

deleted

Boolean

Set to true after deletion so that 'change' event is called and item is removed from UI lists.

id

Integer

Inherited from SharedObject but overwritten in native\PlaylistManage.js:83

Gets playlist id

isAutoPlaylist

Boolean

Gets/Sets whether the playlist is auto-playlist

isObservable

Unknown

Whether this object can be listened (e.g. for 'change' event)

isStatusBarSource

Boolean

Is source for status bar informations.

name

String

Gets/Sets title of this playlist.

objectType

String

Gets the object type as string

parent

Playlist

Gets playlist parent

parentID

Integer

Gets id of parent playlist

persistentID

String

Gets persistent id of the object

supportPin

Boolean

Whether object support pin to pinned list

title

String

Gets the object title

Events

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

playlistAdded

Event is called when a child playlist is created. Most useful with app.playlists.root.

Event Payload:

  • playlistID Integer

    ID of created playlist. (pre version 5.0.4. use app.playlists.getByIDAsync(playlistID) to get the Playlist object).

  • Playlist Playlist

    object. Added in version 5.0.4

playlistChanged

Event is called when a child playlist is modified. Most useful with app.playlists.root.

Event Payload:

  • playlistID Integer

    ID of changed playlist (pre version 5.0.4. use app.playlists.getByIDAsync(playlistID) to get the Playlist object).

  • Playlist Playlist

    object. Added in version 5.0.4

playlistRemoved

Event is called when a child playlist is removed. Most useful with app.playlists.root.

Event Payload:

  • playlist Playlist

    Object containing info of the playlist that was removed.

statuschange

Event is called when status info of the object is changed