Providers

SettingsProvider

The SettingsProvider is a component that manages the state of the video player's settings.

Usage

To use the SettingsProvider, you need to wrap your component with it. This is usually done in the component that contains the video player.

import { SettingsProvider } from 'react-native-video-toolkit';

export const VideoPlayerComponent = () => <SettingsProvider>{/* Your video player content */}</SettingsProvider>;

State

The SettingsProvider manages the following state:

StateTypeDescription
isSettingsMenuVisiblebooleanWhether the settings menu is visible.
videoTrack`VideoTracknull`The current video track.
videoTracksVideoTrack[]The list of available video tracks.
audioTrack`AudioTracknull`The current audio track.
audioTracksAudioTrack[]The list of available audio tracks.
textTrack`TextTracknull`The current subtitle track.
textTracksTextTrack[]The list of available subtitle tracks.
playbackRatenumberThe current playback rate.

Actions

The SettingsProvider handles the following actions:

ActionPayloadDescription
TOGGLE_SETTINGS_MENUToggles the visibility of the settings menu.
SET_VIDEO_TRACK`VideoTracknull`Sets the current video track.
GET_VIDEO_TRACKSVideoTrack[]Sets the list of available video tracks.
SET_AUDIO_TRACK`AudioTracknull`Sets the current audio track.
GET_AUDIO_TRACKSAudioTrack[]Sets the list of available audio tracks.
SET_TEXT_TRACK`TextTracknull`Sets the current subtitle track.
GET_TEXT_TRACKSTextTrack[]Sets the list of available subtitle tracks.
SET_PLAYBACK_RATEnumberSets the playback rate.
OPEN_SETTINGS_SHEETOpens the settings menu.
CLOSE_SETTINGS_SHEETCloses the settings menu.

useSettingsContext

The useSettingsContext hook provides access to the settings state and dispatch function.

Returns

ValueTypeDescription
stateSettingsProviderStateThe settings state.
dispatchReact.Dispatch<SettingsAction>The dispatch function.