Limeplay - Open Source Video Player UI ComponentsLimeplay

use-playlist

Feature for managing playback queue, navigation, shuffle, and repeat modes.

Installation

npx shadcn add @limeplay/use-playlist

Register the feature:

lib/media.ts
"use client"

import { playlistFeature } from "@/hooks/limeplay/use-playlist"

createMediaKit({
  features: [..., playlistFeature()] as const,
})

Store

Access via usePlaylistStore(selector):

import { usePlaylistStore } from "@/hooks/limeplay/use-playlist"

const queue = usePlaylistStore((s) => s.queue)
const currentItem = usePlaylistStore((s) => s.currentItem)
const repeatMode = usePlaylistStore((s) => s.repeatMode)

State

FieldTypeDescription
queuePlaylistItem[]Current playlist items
currentItemPlaylistItem | nullCurrently playing item
currentIndexnumberIndex of current item
repeatMode"off" | "one" | "all"Repeat mode
shufflebooleanShuffle enabled
shuffleOrdernumber[]Randomized indices
historyPlaylistItem[]Playback history
sessionIdstringCurrent session identifier

Actions

MethodDescription
load(items, startIndex?)Load a playlist
next()Advance to next item
previous()Go to previous item (from history)
skipTo(index)Jump to specific index
skipToId(id)Jump to item by ID
append(items)Add items to end
prepend(items)Add items to start
insert(items, atIndex)Insert at position
playNext(items)Insert after current
remove(id)Remove by ID
removeAt(index)Remove by index
reorder(from, to)Move item position
clear()Clear the playlist
setRepeatMode(mode)Set repeat mode
cycleRepeatMode()Cycle through off → one → all
setShuffle(enabled)Enable/disable shuffle
toggleShuffle()Toggle shuffle
newSession()Generate new session ID

usePlaylist Hook

Higher-level hook with derived state:

import { usePlaylist } from "@/hooks/limeplay/use-playlist"

const { next, previous, hasNext, hasPrevious, orderedItems } = usePlaylist()

Events

EventPayloadWhen
playlistchangePlaylistChangeEventCurrent item changes

PlaylistChangeEvent includes currentIndex, currentItem, previousIndex, previousItem, and reason ("load", "next", "previous", "skip", "remove").

On this page