use-captions
Feature for managing captions and text tracks via Shaka Player.
Installation
npx shadcn add @limeplay/use-captionsRegister the feature:
"use client"
import { captionsFeature } from "@/hooks/limeplay/use-captions"
createMediaKit({
features: [..., captionsFeature()] as const,
})Store
Access via useCaptionsStore(selector):
import { useCaptionsStore } from "@/hooks/limeplay/use-captions"
const visible = useCaptionsStore((s) => s.visible)
const tracks = useCaptionsStore((s) => s.tracks)
const activeTrack = useCaptionsStore((s) => s.activeTrack)State
| Field | Type | Description |
|---|---|---|
visible | boolean | Whether captions are visible |
activeTrack | shaka.extern.TextTrack | null | Currently active text track |
tracks | shaka.extern.TextTrack[] | Available text tracks |
containerElement | HTMLDivElement | null | Captions render container |
Actions
| Method | Description |
|---|---|
toggleVisibility() | Toggle caption visibility |
setContainerElement(el) | Set the captions container DOM element |
The feature auto-detects text tracks from the Shaka Player instance and selects a default based on the device language.