Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Example: Activate A Playlist

PlugLynn edited this page Apr 19, 2015 · 2 revisions

Code

Changes the current active playlist to the one by the given ID, and reloads it.

var Events = plugModules.require('plug/core/Events')
var PlaylistActionEvents = plugModules.require('plug/events/PlaylistActionEvent')
var playlists = plugModules.require('plug/collections/playlists')
function activatePlaylist(pid) {
    var target = playlists.findWhere({ id: pid });
    // The ACTIVATE event activates the current selected playlist, so we select it first
    playlists.setVisible(target);
    Events.dispatch(new PlaylistActionEvent(PlaylistActionEvent.ACTIVATE));
    // activating a playlist doesn't automatically load it, so it shows up as an empty
    // playlist initially.
    Events.dispatch(new PlaylistActionEvent(PlaylistActionEvent.LOAD));
}

Usage

activatePlaylist(playlistId)
Clone this wiki locally