{"id":18927497,"url":"https://github.com/jakemmarsh/playback-queue","last_synced_at":"2025-04-15T13:33:54.024Z","repository":{"id":57151812,"uuid":"41284816","full_name":"jakemmarsh/playback-queue","owner":"jakemmarsh","description":"A fully-featured and generic playback queue for music objects including history, shuffle, and repeat.","archived":false,"fork":false,"pushed_at":"2016-01-23T06:23:20.000Z","size":27,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T08:47:43.371Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakemmarsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-24T05:54:02.000Z","updated_at":"2022-10-29T12:04:59.000Z","dependencies_parsed_at":"2022-08-31T20:10:30.038Z","dependency_job_id":null,"html_url":"https://github.com/jakemmarsh/playback-queue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakemmarsh%2Fplayback-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakemmarsh%2Fplayback-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakemmarsh%2Fplayback-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakemmarsh%2Fplayback-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakemmarsh","download_url":"https://codeload.github.com/jakemmarsh/playback-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249080610,"owners_count":21209548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:19:21.962Z","updated_at":"2025-04-15T13:33:53.758Z","avatar_url":"https://github.com/jakemmarsh.png","language":"JavaScript","readme":"# playback-queue [![npm version](https://badge.fury.io/js/playback-queue.svg)](https://badge.fury.io/js/playback-queue)\nA fully-featured and generic playback queue for music objects including history, shuffle, and repeat.\n\n## Usage\n`npm install --save playback-queue`\n\n```js\n  import PlaybackQueue from 'playback-queue';\n\n  const options = {};\n  const queue = new PlaybackQueue(options);\n```\n\n## Options\n- **`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.\n  - **type:** `array`\n  - **default:** `[]`\n- **`shuffle`:** A flag indicating whether or not playback (and returned tracks) should be randomly shuffled.\n  - **type:** `boolean`\n  - **default:** `false`\n- **`repeat`:** A string indicating how playback should be repeated.\n  - **type:** `string`\n  - **values:** `['playlist', 'track', 'none']`\n  - **default:** `'playlist`'\n\n## API\nPlaybackQueue, 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 (`_`).\n\n#### Methods\n##### `setTracks(tracks)`\nManually sets the playlist of tracks in the queue, then resets all states (except shuffle and repeat) and selects the first track.\n\n##### `nextTrack()`\nSelects and returns the next track to be played, based on current repeat and shuffle states. Updates state and queues accordingly.\n\n##### `previousTrack()`\nSelects and returns the previous track played based on play history. Returns previous song in current playlist if no history. Updates state and queues accordingly.\n\n##### `selectTrack(track)`\nManually selects the given track, updating state and queues accordingly. **Note:** Throws an error if provided track is not in current playlist.\n\n##### `toggleShuffle()`\nToggles the shuffle state between shuffled and not shuffled.\n\n##### `toggleRepeat()`\nToggles the shuffle state between 'playlist', 'track', and 'none'.\n\n##### `sortTracks(attr, asc)`\nSorts 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`.\n\n#### Properties\n- `queuePool`\n- `currentTrack`\n- `currentIndex`\n- `isShuffled`\n- `repeatState`\n- `shufflePool`\n- `shuffleIndex`\n- `playHistory`\n- `historyIndex`\n\n## Running tests\n\n1. `git clone https://github.com/jakemmarsh/playback-queue.git`\n2. `cd playback-queue`\n3. `npm install`\n4. `npm test` (or `npm run test-watch` to continuously run on file change)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakemmarsh%2Fplayback-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakemmarsh%2Fplayback-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakemmarsh%2Fplayback-queue/lists"}