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:
| State | Type | Description | |
|---|---|---|---|
isSettingsMenuVisible | boolean | Whether the settings menu is visible. | |
videoTrack | `VideoTrack | null` | The current video track. |
videoTracks | VideoTrack[] | The list of available video tracks. | |
audioTrack | `AudioTrack | null` | The current audio track. |
audioTracks | AudioTrack[] | The list of available audio tracks. | |
textTrack | `TextTrack | null` | The current subtitle track. |
textTracks | TextTrack[] | The list of available subtitle tracks. | |
playbackRate | number | The current playback rate. |
Actions
The SettingsProvider handles the following actions:
| Action | Payload | Description | |
|---|---|---|---|
TOGGLE_SETTINGS_MENU | Toggles the visibility of the settings menu. | ||
SET_VIDEO_TRACK | `VideoTrack | null` | Sets the current video track. |
GET_VIDEO_TRACKS | VideoTrack[] | Sets the list of available video tracks. | |
SET_AUDIO_TRACK | `AudioTrack | null` | Sets the current audio track. |
GET_AUDIO_TRACKS | AudioTrack[] | Sets the list of available audio tracks. | |
SET_TEXT_TRACK | `TextTrack | null` | Sets the current subtitle track. |
GET_TEXT_TRACKS | TextTrack[] | Sets the list of available subtitle tracks. | |
SET_PLAYBACK_RATE | number | Sets the playback rate. | |
OPEN_SETTINGS_SHEET | Opens the settings menu. | ||
CLOSE_SETTINGS_SHEET | Closes the settings menu. |
useSettingsContext
The useSettingsContext hook provides access to the settings state and dispatch function.
Returns
| Value | Type | Description |
|---|---|---|
state | SettingsProviderState | The settings state. |
dispatch | React.Dispatch<SettingsAction> | The dispatch function. |