mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
27 lines
875 B
TypeScript
27 lines
875 B
TypeScript
'use client';
|
|
|
|
import { CaptionsButtonCore, CaptionsButtonDataAttrs } from '@videojs/core';
|
|
import { selectTextTrack } from '@videojs/core/dom';
|
|
|
|
import type { UIComponentProps } from '../../utils/types';
|
|
import { createMediaButton } from '../create-media-button';
|
|
|
|
export interface CaptionsButtonProps
|
|
extends UIComponentProps<'button', CaptionsButtonCore.State>,
|
|
CaptionsButtonCore.Props {}
|
|
|
|
/** A button that toggles captions. */
|
|
export const CaptionsButton = createMediaButton<CaptionsButtonCore, CaptionsButtonProps>({
|
|
displayName: 'CaptionsButton',
|
|
core: CaptionsButtonCore,
|
|
stateAttrMap: CaptionsButtonDataAttrs,
|
|
selector: selectTextTrack,
|
|
action: (core, state) => core.toggle(state),
|
|
hotkeyAction: 'toggleSubtitles',
|
|
});
|
|
|
|
export namespace CaptionsButton {
|
|
export type Props = CaptionsButtonProps;
|
|
export type State = CaptionsButtonCore.State;
|
|
}
|