🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

playback-queue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

playback-queue

A node module for creating and operating on a playback queue. Includes history, shuffling, and repetition.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

playback-queue

A node module for creating and operating on a music playback queue. Includes history, shuffling, and repeating.

Usage

npm install --save playback-queue

  import PlaybackQueue from 'playback-queue'

  const options = {};
  const queue = new PlaybackQueue(options);

Options

  • tracks: An array of tracks (or any other object you want in the queue). These will be the objects processed and returned by the queue.
    • type: array
    • default: []
  • shuffle: A flag indicating whether or not playback (and returned tracks) should be randomly shuffled.
    • type: boolean
    • default: false
  • repeat: A string indicating how playback should be repeated.
    • type: string
    • values: ['playlist', 'track', 'none']
    • default: 'playlist'

API

PlaybackQueue, once instantiated, exposes a handful of methods with which to operate on the queue and retrieve objects. Any methods not intended for outside use are prefixed with an underscore (_).

Methods

setTracks(tracks)

Manually sets the playlist of tracks in the queue, then resets all states (except shuffle and repeat) and selects the first track.

nextTrack()

Selects and returns the next track to be played, based on current repeat and shuffle states. Updates state and queues accordingly.

previousTrack()

Selects and returns the previous track played based on play history. Returns previous song in current playlist if no history. Updates state and queues accordingly.

selectTrack(track)

Manually selects the given track, updating state and queues accordingly. Note: Throws an error if provided track is not in current playlist.

toggleShuffle()

Toggles the shuffle state between shuffled and not shuffled.

toggleRepeat()

Toggles the shuffle state between 'playlist', 'track', and 'none'.

sortTracks(attr, asc)

Sorts the current playlist by the provided attribute (key). Also takes an asc parameter, specifying whether the sort should be ascending or not. Defaults to true.

Properties

  • queuePool
  • currentTrack
  • currentIndex
  • isShuffled
  • repeatState
  • shufflePool
  • shuffleIndex
  • playHistory
  • historyIndex

Running tests

  • git clone https://github.com/jakemmarsh/playback-queue.git
  • cd playback-queue
  • npm install
  • npm test (or npm run test-watch to continuously run on file change)

Keywords

song

FAQs

Package last updated on 23 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts