### Vega SDK setup and build commands
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Installs and uses Vega SDK 2.0, sets up the environment, and builds the Vega debug bundle. Requires Node.js 22.14.0+ and a device running Vega OS 2.0. Keep the checkout path free of spaces.
```bash
vega sdk install 0.24.12112
vega sdk use 0.24.12112
source ~/vega/env
vega --version
yarn install --immutable
yarn build:vega:debug
```
--------------------------------
### Run Web development server
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Starts the Web development server for the expo-multi-tv app.
```bash
yarn dev:web
```
--------------------------------
### Start Metro bundler for Android TV
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Starts the Metro bundler for the expo-multi-tv app. Run this before running on Android TV.
```bash
yarn dev
```
--------------------------------
### Clone and install dependencies
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Clones the repository and installs all dependencies using Yarn. Requires Node.js v22.14.0+ and Yarn v4.5.0.
```bash
# Clone the repository
git clone https://github.com/AmazonAppDev/react-native-multi-tv-app-sample.git
cd react-native-multi-tv-app-sample
# Install all dependencies
yarn install
```
--------------------------------
### Run universal app on different platforms
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Quick start commands to run the app on Android TV, Fire TV FOS, Apple TV, and Web.
```bash
# Android TV and Fire TV FOS
yarn dev:android
# Apple TV
yarn dev:ios
# Web
yarn dev:web
```
--------------------------------
### Usage as Scrim Overlay in HomeScreen
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example usage in `HomeScreen`'s `renderHeader` as a scrim overlay. The `start` and `end` props are accepted but ignored; the rendered background is the last color in the array ('transparent').
```tsx
```
--------------------------------
### Run on Apple TV
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Runs the app on Apple TV. Use after starting the Metro bundler.
```bash
yarn dev:ios
```
--------------------------------
### Start Metro on alternate port
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Use port 8082 if the default Metro port 8081 is already in use.
```bash
yarn start --port 8082
```
--------------------------------
### Run on Android TV
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Runs the app on Android TV. Use after starting the Metro bundler.
```bash
yarn dev:android
```
--------------------------------
### Controls usage example
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example usage of the Controls component with props for paused state, toggle handler, current time, and duration.
```TSX
```
--------------------------------
### Navigate to Details from a custom screen
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example of navigating to the Details screen with the required parameters.
```tsx
navigation.navigate('Details', {
title: 'Title',
description: '…',
headerImage: 'https://…/poster.jpg',
movie: 'https://…/movie.mp4',
duration: 7200,
});
```
--------------------------------
### Vega/Kepler TVEventHandler setup (RemoteControlManager.kepler.ts)
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Enables TVEventHandler and maps normalized and raw event names to SupportedKeys. handleHWEvent only emits when eventKeyAction is 0 or undefined.
```typescript
this.tvEventHandler = new TVEventHandler();
this.tvEventHandler.enable(this, this.handleHWEvent);
```
```typescript
const EVENT_TYPE_MAPPING: Record = {
left: SupportedKeys.Left,
right: SupportedKeys.Right,
down: SupportedKeys.Down,
up: SupportedKeys.Up,
select: SupportedKeys.Enter,
enter: SupportedKeys.Enter,
back: SupportedKeys.Back,
playpause: SupportedKeys.PlayPause,
skip_backward: SupportedKeys.Rewind,
rewind: SupportedKeys.Rewind,
skip_forward: SupportedKeys.FastForward,
fastforward: SupportedKeys.FastForward,
forward: SupportedKeys.FastForward,
};
```
--------------------------------
### Shared Component Example: MyComponent
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Shows how to create a shared component in shared-ui, export it from the index, and import it in an app. Use this pattern when adding new features to the monorepo.
```typescript
// packages/shared-ui/src/components/MyComponent.tsx
export const MyComponent = () => {
/* ... */
};
// packages/shared-ui/src/index.ts
export { MyComponent } from './components/MyComponent';
// apps/expo-multi-tv/App.tsx
import { MyComponent } from '@multi-tv/shared-ui';
```
--------------------------------
### Initialize VideoHandler with Vega
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Creates a VideoHandler instance with a video reference, movie URI, poster URI, and state setters. Call preBufferVideo to start buffering.
```tsx
const videoRef = useRef(null);
const videoHandlerRef = useRef(null);
videoHandlerRef.current = new VideoHandler(
videoRef,
movie, // videoUri
headerImage, // posterUri
setIsVideoInitialized,
setIsVideoEnded,
setIsVideoError,
setCurrentTime,
setDuration,
setIsVideoBuffering,
);
videoHandlerRef.current.preBufferVideo(componentInstance);
```
--------------------------------
### VegaRootNavigator stack setup
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Defines the root stack navigator for the Vega app, registering Main, Details, and Player screens with headers hidden. DetailsScreen and PlayerScreen are imported from @multi-tv/shared-ui and resolve to .vega.tsx variants on the Vega bundler.
```tsx
const Stack = createNativeStackNavigator();
export default function VegaRootNavigator() {
return (
);
}
```
--------------------------------
### Clean and reinstall CocoaPods
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Remove the Pods directory and lockfile, then reinstall dependencies to fix Pods installation issues.
```bash
cd apps/expo-multi-tv/ios
rm -rf Pods Podfile.lock
pod install
```
--------------------------------
### Basic usage of FocusablePressable
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example usage as a basic button, as used in Controls.tsx, ExitButton.tsx, and DetailsScreen.tsx.
```tsx
import { FocusablePressable } from '@multi-tv/shared-ui';
;
```
--------------------------------
### Usage in StyleSheet with scaledPixels
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example of using scaledPixels for padding, border radius, and min width in a StyleSheet.
```tsx
const styles = StyleSheet.create({
button: {
paddingVertical: scaledPixels(20),
paddingHorizontal: scaledPixels(40),
borderRadius: scaledPixels(8),
minWidth: scaledPixels(200),
},
});
```
--------------------------------
### Usage in PlayerScreen
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example usage of VideoOverlay in PlayerScreen.tsx, conditionally rendered when native controls are not shown and duration is available.
```tsx
{!SHOW_NATIVE_CONTROLS && !!durationRef.current && (
navigation.goBack()}
currentTime={currentTime}
duration={durationRef.current}
isBuffering={isVideoBuffering}
/>
)}
```
--------------------------------
### SeekBar usage example
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Basic usage of the SeekBar component with currentTime and duration props from a player reference.
```TSX
```
--------------------------------
### Toggle setting pattern with FocusablePressable
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example of a toggle button using FocusablePressable, reflecting the current state in the label and updating it on select.
```tsx
setNotifications(!notifications)}
style={styles.toggleButton}
/>
```
--------------------------------
### handleStartOver(mediaSessionId?)
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Handles the start over media control. If client override is needed, it resets the video player's current time to zero and plays; otherwise, it delegates to the base class implementation.
```APIDOC
## handleStartOver(mediaSessionId?: IMediaSessionId): Promise
### Description
Handles the start over media control. If client override is needed, it resets the video player's current time to zero and plays; otherwise, it delegates to the base class implementation.
### Method
handleStartOver
### Parameters
- `mediaSessionId` (IMediaSessionId) - Optional - Session id passed to the base-class handler
### Return Type
Promise
```
--------------------------------
### Production build for Web
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Builds the Web app for production and serves it locally.
```bash
cd apps/expo-multi-tv
npx expo export --platform web
npx serve dist
```
--------------------------------
### App-specific commands for expo-multi-tv and vega
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Commands to run, test, and lint each app. Navigate to the app directory first.
```bash
# expo-multi-tv
cd apps/expo-multi-tv
yarn start # Start Metro bundler
yarn android # Run on Android TV
yarn ios # Run on Apple TV
yarn web # Run on Web
yarn test # Run tests
yarn lint # Lint code
# vega
cd apps/vega
yarn start # Start Metro bundler
yarn build # Build for Fire TV
yarn test # Run tests
yarn lint # Lint code
```
--------------------------------
### setupEventListeners(): void
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Adds event listeners for loadedmetadata, timeupdate, ended, error, waiting, seeking, seeked, and playing events.
```APIDOC
## setupEventListeners(): void
### Description
Adds event listeners for loadedmetadata, timeupdate, ended, error, waiting, seeking, seeked, and playing events.
### Method
setupEventListeners
### Returns
void
```
--------------------------------
### Build Fire TV directly from app directory
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Builds the Fire TV app directly from the vega app directory.
```bash
cd apps/vega
yarn build
```
--------------------------------
### Conditional sizing with scaledPixels
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example of using scaledPixels for an item size prop.
```tsx
itemSize={scaledPixels(440)} // horizontal list item size
```
--------------------------------
### Fire TV (Vega) build commands
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Development, production, and debug builds for Fire TV using the Vega workspace.
```bash
# Development build
yarn dev:vega
# Production build
yarn build:vega
# Debug build
yarn build:vega:debug
```
--------------------------------
### Run Web directly from app directory
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Runs the Web app directly from the expo-multi-tv app directory.
```bash
cd apps/expo-multi-tv
yarn web
```
--------------------------------
### Check Vega SDK path
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Verify the Vega SDK environment variable is set correctly.
```bash
echo $KEPLER_SDK_HOME
```
--------------------------------
### Clean and reinstall dependencies
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Clear caches and reinstall packages to resolve 'Module not found' errors.
```bash
yarn clean:all
yarn install
```
--------------------------------
### Check ADB devices and connect to TV
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
List connected devices and connect to an Android TV or Fire TV over the network using its IP address.
```bash
adb devices
adb connect :5555
```
--------------------------------
### RootNavigator and DrawerNavigator
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Navigation components for the app.
```APIDOC
## RootNavigator and DrawerNavigator
### Description
Navigation components for the app.
### Components
- `RootNavigator` (Component) - Root stack navigator.
- `DrawerNavigator` (Component) - Drawer navigator.
### Source
`packages/shared-ui/src/navigation/`
### Usage
```tsx
import { RootNavigator, DrawerNavigator } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Close drawer using getCloseDrawerDirection
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example from drawer content: closes the drawer when movement matches the close direction.
```tsx
import { getCloseDrawerDirection } from '@multi-tv/shared-ui';
const onDirectionHandledWithoutMovement = useCallback(
(movement: Direction) => {
if (movement === getCloseDrawerDirection()) {
navigation.closeDrawer();
toggleMenu(false);
}
},
[navigation, toggleMenu],
);
```
--------------------------------
### MenuProvider and useMenuContext
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Context provider and hook for managing menu state.
```APIDOC
## MenuProvider and useMenuContext
### Description
Context provider and hook for managing menu state.
### Exports
- `MenuProvider` (Component) - Provider component.
- `useMenuContext` (Hook) - Hook to access menu context.
### Source
`packages/shared-ui/src/components/MenuContext.tsx`
### Usage
```tsx
import { MenuProvider, useMenuContext } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Run Android TV directly from app directory
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Runs the app on Android TV directly from the expo-multi-tv app directory.
```bash
cd apps/expo-multi-tv
yarn android
```
--------------------------------
### PlatformLinearGradient Props Interface
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Defines the props accepted by the component. Only `colors` and `style` are used; `start`, `end`, `locations` are accepted for API parity but ignored.
```ts
interface PlatformLinearGradientProps {
colors: string[];
style?: StyleProp;
start?: { x: number; y: number };
end?: { x: number; y: number };
locations?: number[];
children?: ReactNode;
}
```
--------------------------------
### Open drawer using getOpenDrawerDirection
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example from HomeScreen/ExploreScreen/TVScreen: opens the drawer when movement matches the open direction and focusedIndex is 0.
```tsx
import { getOpenDrawerDirection } from '@multi-tv/shared-ui';
const onDirectionHandledWithoutMovement = useCallback(
(movement: Direction) => {
if (movement === getOpenDrawerDirection() && focusedIndex === 0) {
navigation.dispatch(DrawerActions.openDrawer());
toggleMenu(true);
}
},
[toggleMenu, focusedIndex, navigation],
);
```
--------------------------------
### SeekBar usage with duration guard
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Usage example that guards against zero or NaN duration before rendering SeekBar, matching the component's internal check.
```TSX
// guard against zero/NaN duration as the component does internally
if (duration > 0) return ;
```
--------------------------------
### Import theme constants from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows how to import the theme constants in a consumer. All constants are read-only object literals.
```typescript
import { colors, spacing, typography, safeZones } from '@multi-tv/shared-ui';
```
--------------------------------
### ExitButton Usage in Error State
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example usage of ExitButton within PlayerScreen.vega's error state. Wrapped in SpatialNavigationRoot and positioned inside an error container.
```tsx
if (isVideoError) {
return (
);
}
```
--------------------------------
### Run Apple TV directly from app directory
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Runs the app on Apple TV directly from the expo-multi-tv app directory.
```bash
cd apps/expo-multi-tv
yarn ios
```
--------------------------------
### KeplerVideoRef interface definition
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Defines the imperative handle exposed by the Vega VideoPlayer to mirror react-native-video's VideoRef interface. Provides methods to get current time, duration, and paused state, with fallback values when the underlying player is null.
```TypeScript
export interface KeplerVideoRef {
/** W3C Media VideoPlayer instance */
videoPlayer: W3CVideoPlayer | null;
/** Get current playback time */
getCurrentTime: () => number;
/** Get total video duration */
getDuration: () => number;
/** Check if video is paused */
isPaused: () => boolean;
}
```
--------------------------------
### PlatformLinearGradient Component Implementation
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Renders a View with a solid background using the last color in the `colors` array. Falls back to 'rgba(0, 0, 0, 0.6)' if `colors` is empty or undefined. The `start`, `end`, and `locations` props are ignored.
```tsx
const PlatformLinearGradient: React.FC = ({
colors,
style,
children,
}) => {
const fallbackColor = colors && colors.length > 0
? colors[colors.length - 1]
: 'rgba(0, 0, 0, 0.6)';
return (
,
{ backgroundColor: fallbackColor },
]}
>
{children}
);
};
```
--------------------------------
### Vega app.json configuration
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Declares the app name and display name for the Vega app. The name must follow the pattern shown to be KRL-compatible.
```json
{ "name": "com.giolaq.multitv.vega.main", "displayName": "MultiTVVega" }
```
--------------------------------
### Usage: load movies in useEffect with error handling
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Example of calling fetchMoviesData inside a React effect, managing loading state and handling errors by logging and rendering fallback UI.
```tsx
useEffect(() => {
const loadMovies = async () => {
try {
setIsLoading(true);
const movies = await fetchMoviesData();
setMoviesData(movies);
} catch (error) {
console.error('Failed to load movies:', error);
// render fallback UI
} finally {
setIsLoading(false);
}
};
loadMovies();
}, []);
```
--------------------------------
### Import DrawerNavigator
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the DrawerNavigator component from the '@multi-tv/shared-ui' package.
```ts
import { DrawerNavigator } from '@multi-tv/shared-ui';
```
--------------------------------
### RTL Utilities
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Utility functions for right-to-left layout support.
```APIDOC
## RTL Utilities
### Description
Utility functions for right-to-left layout support.
### Functions
- `isRTL` (function) - Returns whether the app is in RTL mode.
- `getOpenDrawerDirection` (function) - Returns the direction to open the drawer.
- `getCloseDrawerDirection` (function) - Returns the direction to close the drawer.
### Source
`packages/shared-ui/src/utils/rtl.ts`
### Usage
```tsx
import { isRTL, getOpenDrawerDirection, getCloseDrawerDirection } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Import VideoOverlay
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Import the default export from the player components directory. The Vega variant resolves automatically via sourceExts.
```ts
import VideoOverlay from '../components/player/VideoOverlay';
// Vega variant resolves automatically via sourceExts ['vega.tsx', …]
```
--------------------------------
### Screens
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Screen components for the TV app.
```APIDOC
## Screens
### Description
Screen components for the TV app.
### Exports
- `HomeScreen` (Component) - Home screen.
- `DetailsScreen` (Component) - Details screen.
- `PlayerScreen` (Component) - Player screen.
- `ExploreScreen` (Component) - Explore screen.
- `TVScreen` (Component) - TV screen.
- `SettingsScreen` (Component) - Settings screen.
### Source
`packages/shared-ui/src/screens/`
### Usage
```tsx
import { HomeScreen, DetailsScreen, PlayerScreen, ExploreScreen, TVScreen, SettingsScreen } from '@multi-tv/shared-ui';
```
```
--------------------------------
### play(): void
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Plays the video. On Kepler, calls videoRef.current.play(). On stub, logs only.
```APIDOC
## play(): void
### Description
Plays the video. On Kepler, calls videoRef.current.play(). On stub, logs only.
### Method
play
### Returns
void
```
--------------------------------
### Import MenuProvider and useMenuContext
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Import statement for consuming MenuProvider and useMenuContext from the @multi-tv/shared-ui package.
```ts
import { MenuProvider, useMenuContext } from '@multi-tv/shared-ui';
```
--------------------------------
### Provide MenuProvider at app root
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Wrap the app with MenuProvider at the root. Already done by AppNavigator/VegaAppNavigator.
```tsx
```
--------------------------------
### Theme Constants
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Theme constants for colors, spacing, typography, and safe zones.
```APIDOC
## Theme Constants
### Description
Theme constants for colors, spacing, typography, and safe zones.
### Exports
- `colors` (object) - Color palette.
- `spacing` (object) - Spacing scale.
- `typography` (object) - Typography styles.
- `safeZones` (object) - Safe area zones.
### Source
`packages/shared-ui/src/theme/`
### Usage
```tsx
import { colors, spacing, typography, safeZones } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Set Node binary path in .xcode.env.local
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Update the Node binary path in the Xcode environment file to resolve 'No such file or directory: node' errors. Replace with the output of 'which node'.
```bash
export NODE_BINARY=/opt/homebrew/bin/node # or your node path
```
--------------------------------
### MenuProvider
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Provides the menu context to its children. It initializes the drawer open state to true and exposes a toggle function.
```APIDOC
## MenuProvider
### Description
Provides the menu context to its children. It initializes the drawer open state to true and exposes a toggle function.
### Parameters
- `children` (React.ReactNode) - Required - Subtree that may consume the context.
### Return Type
`ReactElement` - The context provider. Note that `MenuProvider` is a named (non-default) export and is a plain `React.FC` (no `memo`).
### Example
```tsx
```
```
--------------------------------
### CustomDrawerContent
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Custom content for the drawer navigator.
```APIDOC
## CustomDrawerContent
### Description
Custom content for the drawer navigator.
### Component
`CustomDrawerContent`
### Source
`packages/shared-ui/src/components/CustomDrawerContent.tsx`
### Usage
```tsx
import { CustomDrawerContent } from '@multi-tv/shared-ui';
```
```
--------------------------------
### FocusablePressable
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
A pressable component that supports TV focus management.
```APIDOC
## FocusablePressable
### Description
A pressable component that supports TV focus management.
### Component
`FocusablePressable`
### Source
`packages/shared-ui/src/components/FocusablePressable.tsx`
### Usage
```tsx
import { FocusablePressable } from '@multi-tv/shared-ui';
```
```
--------------------------------
### DrawerNavigator component implementation
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Full implementation of the DrawerNavigator component. It creates a drawer navigator with four screens (Home, Explore, TV, Settings) and uses MenuContext for drawer state. On TV platforms, it wraps in a plain View; otherwise, it uses GestureHandlerRootView for swipe gestures.
```tsx
import { createDrawerNavigator } from '@react-navigation/drawer';
const Drawer = createDrawerNavigator();
export default function DrawerNavigator() {
const { isOpen: isMenuOpen } = useMenuContext();
const drawerNavRef = useRef | null>(null);
const navigationContent = (
{() => (
<>
>
)}
);
if (Platform.isTV) {
return {navigationContent};
}
return (
{navigationContent}
);
}
```
--------------------------------
### Basic App initialization with Expo fonts
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows how to use AppNavigator with expo-font and splash screen. Includes a side-effect import for remote control configuration. The component is rendered with fontsLoaded set to true when fonts are loaded or an error occurred.
```tsx
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { AppNavigator } from '@multi-tv/shared-ui';
// side-effect import wires remote keys into react-tv-space-navigation
import '../../packages/shared-ui/src/app/configureRemoteControl';
SplashScreen.preventAutoHideAsync();
export default function App() {
const [loaded, error] = useFonts({
SpaceMono: require('./assets/fonts/SpaceMono-Regular.ttf'),
});
useEffect(() => {
if (loaded || error) SplashScreen.hideAsync();
}, [loaded, error]);
return ;
}
```
--------------------------------
### Import ExploreScreen and TVScreen from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the placeholder screens for use in drawer navigation.
```ts
import { ExploreScreen, TVScreen } from '@multi-tv/shared-ui';
```
--------------------------------
### AppNavigator with onReady callback
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows how to pass an onReady callback to AppNavigator, e.g., for analytics. The callback is invoked when fontsLoaded becomes truthy.
```tsx
{
console.log('Navigation ready');
}}
/>
```
--------------------------------
### LoadingIndicator
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
A loading indicator component for TV screens.
```APIDOC
## LoadingIndicator
### Description
A loading indicator component for TV screens.
### Component
`LoadingIndicator`
### Source
`packages/shared-ui/src/components/LoadingIndicator.tsx`
### Usage
```tsx
import { LoadingIndicator } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Import FocusablePressable
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the FocusablePressable component from the @multi-tv/shared-ui package.
```ts
import { FocusablePressable } from '@multi-tv/shared-ui';
```
--------------------------------
### AppNavigator
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
The main navigation component for the TV app. It sets up the root stack and drawer navigators.
```APIDOC
## AppNavigator
### Description
The main navigation component for the TV app. It sets up the root stack and drawer navigators.
### Component
`AppNavigator` (with `AppNavigatorProps`)
### Source
`packages/shared-ui/src/navigation/AppNavigator.tsx`
### Props
- `AppNavigatorProps` (object) - Required - Props for the navigator.
### Usage
```tsx
import { AppNavigator } from '@multi-tv/shared-ui';
```
```
--------------------------------
### ExploreScreen component implementation
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Placeholder screen with drawer-open gesture and a single focusable label. Uses SpatialNavigationRoot, DefaultFocus, and useMenuContext.
```tsx
export default function ExploreScreen() {
const styles = exploreStyles;
const { isOpen: isMenuOpen, toggleMenu } = useMenuContext();
const isFocused = useIsFocused();
const isActive = isFocused && !isMenuOpen;
const navigation = useNavigation();
const [focusedIndex, setFocusedIndex] = useState(0);
const onDirectionHandledWithoutMovement = useCallback(
(movement: Direction) => {
if (movement === getOpenDrawerDirection() && focusedIndex === 0) {
navigation.dispatch(DrawerActions.openDrawer());
toggleMenu(true);
}
},
[toggleMenu, focusedIndex, navigation],
);
return (
Explore Screen
);
}
```
--------------------------------
### Navigation Types
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Type definitions for navigation parameters.
```APIDOC
## Navigation Types
### Description
Type definitions for navigation parameters.
### Types
- `RootStackParamList` (type) - Parameter list for the root stack.
- `DrawerParamList` (type) - Parameter list for the drawer.
### Source
`packages/shared-ui/src/navigation/types.ts`
### Usage
```tsx
import { RootStackParamList, DrawerParamList } from '@multi-tv/shared-ui';
```
```
--------------------------------
### GoBackConfiguration component
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Renders null; subscribes to SupportedKeys.Back and calls navigation.goBack() when canGoBack(). Requires MenuProvider and NavigationContainer ancestors. Mounted by AppNavigator inside the provider.
```tsx
export const GoBackConfiguration: React.FC = () => {
const navigation = useNavigation();
const { isOpen: isMenuOpen } = useMenuContext();
const handleBackPress = useCallback(() => {
if (navigation.canGoBack()) {
navigation.goBack();
if (isMenuOpen) {
console.log('Menu is open during back navigation');
}
}
}, [navigation, isMenuOpen]);
…
};
```
--------------------------------
### Import RootNavigator from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the RootNavigator component from the shared UI package.
```typescript
import { RootNavigator } from '@multi-tv/shared-ui';
```
--------------------------------
### VideoHandler
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Class for handling video playback.
```APIDOC
## VideoHandler
### Description
Class for handling video playback.
### Class
`VideoHandler`
### Source
`packages/shared-ui/src/utils/VideoHandler.ts` / `VideoHandler.kepler.ts` (platform-resolved)
### Usage
```tsx
import { VideoHandler } from '@multi-tv/shared-ui';
```
```
--------------------------------
### Navigate to Details screen from a list
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows how to navigate to the Details screen with all required route parameters, as done in HomeScreen.
```tsx
navigation.navigate('Details', {
title: item.title,
description: item.description,
headerImage: item.headerImage,
movie: item.movie,
category: item.category,
genres: item.genres,
releaseYear: item.releaseYear,
rating: item.rating,
ratingCount: item.ratingCount,
contentRating: item.contentRating,
duration: item.duration,
});
```
--------------------------------
### VegaAppNavigator signature and implementation
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
The default exported navigation component. It accepts optional fontsLoaded and onReady props. When fontsLoaded is false, it returns null. It sets up remote control configuration on TV platforms and renders the navigation tree with GestureHandlerRootView, NavigationContainer (DarkTheme), MenuProvider, and VegaRootNavigator.
```ts
export interface VegaAppNavigatorProps {
fontsLoaded?: boolean;
onReady?: () => void;
}
export default function VegaAppNavigator({ fontsLoaded = true, onReady }: VegaAppNavigatorProps) {
useEffect(() => {
if (Platform.isTV) {
try {
require('@multi-tv/shared-ui/src/app/configureRemoteControl');
} catch (error) {
console.warn('Remote control configuration not available:', error);
}
}
}, []);
useEffect(() => {
if (fontsLoaded && onReady) {
onReady();
}
}, [fontsLoaded, onReady]);
if (!fontsLoaded) {
return null;
}
return (
);
}
```
--------------------------------
### Consume useMenuContext in HomeScreen
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Opens the drawer from HomeScreen. Uses toggleMenu(true) after dispatching DrawerActions.openDrawer() when movement matches getOpenDrawerDirection() and focusedIndex is 0.
```tsx
const { isOpen: isMenuOpen, toggleMenu } = useMenuContext();
const isActive = isFocused && !isMenuOpen;
const onDirectionHandledWithoutMovement = useCallback(
(movement: Direction) => {
if (movement === getOpenDrawerDirection() && focusedIndex === 0) {
navigation.dispatch(DrawerActions.openDrawer());
toggleMenu(true);
}
},
[toggleMenu, focusedIndex, navigation],
);
```
--------------------------------
### Register Explore and TV screens as drawer routes
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Registers the placeholder screens in the drawer navigator with labels 'Explore' and 'TV'.
```tsx
```
--------------------------------
### Wrap HomeScreen with NavigationContainer and MenuProvider
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows the required providers for HomeScreen to work standalone.
```tsx
```
--------------------------------
### Import VideoHandler and VideoFileTypes
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Shows how to import VideoHandler from the package entry and VideoFileTypes via deep import, since it is not exported from the package entry.
```typescript
import { VideoHandler } from '@multi-tv/shared-ui';
import { VideoFileTypes } from '@multi-tv/shared-ui/src/utils/VideoHandler'; // deep import
```
--------------------------------
### onLoadedMetadata(): void
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Event handler for loaded metadata. Sets duration and marks video as initialized.
```APIDOC
## onLoadedMetadata(): void
### Description
Event handler for loaded metadata. Sets duration and marks video as initialized.
### Method
onLoadedMetadata
### Returns
void
```
--------------------------------
### Import AppNavigator from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the AppNavigator component from the shared-ui package.
```ts
import { AppNavigator } from '@multi-tv/shared-ui';
```
--------------------------------
### Import DetailsScreen from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the DetailsScreen component from the shared UI package.
```typescript
import { DetailsScreen } from '@multi-tv/shared-ui';
```
--------------------------------
### Toggle with auto-hide (showControls pattern)
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Pattern for showing controls and auto-hiding after 5 seconds. Clears any existing timeout before setting a new one.
```tsx
const showControls = useCallback(() => {
setControlsVisible(true);
if (hideControlsTimeoutRef.current) clearTimeout(hideControlsTimeoutRef.current);
hideControlsTimeoutRef.current = setTimeout(() => setControlsVisible(false), 5000);
}, []);
```
--------------------------------
### AppNavigator render tree with StrictMode and providers
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
The JSX tree rendered when fontsLoaded is true. Element order is significant: GoBackConfiguration must be under MenuProvider because it uses useMenuContext.
```tsx
```
--------------------------------
### onWaiting() / onSeeking(): void
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Event handlers for waiting and seeking events. Show buffering indicator.
```APIDOC
## onWaiting() / onSeeking(): void
### Description
Event handlers for waiting and seeking events. Show buffering indicator.
### Method
onWaiting / onSeeking
### Returns
void
```
--------------------------------
### Import SettingsScreen
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the SettingsScreen component from the @multi-tv/shared-ui package.
```ts
import { SettingsScreen } from '@multi-tv/shared-ui';
```
--------------------------------
### AppNavigator
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Root application component for the universal app. Mounts the navigation container, menu provider, remote-control back handling, and the root navigator stack. Accepts optional props for font loading and an onReady callback.
```APIDOC
## AppNavigator
### Description
Root application component for the universal (`expo-multi-tv`) app: mounts the `NavigationContainer`, `MenuProvider`, remote-control back handling and the `RootNavigator` stack.
### Signature
```ts
export interface AppNavigatorProps {
fontsLoaded?: boolean;
onReady?: () => void;
}
export default function AppNavigator({ fontsLoaded = true, onReady }: AppNavigatorProps) { … }
```
### Parameters
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `fontsLoaded` | `boolean` | no | `true` | Gate for mounting the navigation tree. When `false` the component returns `null`. |
| `onReady` | `() => void` | no | `undefined` | Invoked by a `useEffect` whenever `fontsLoaded` becomes truthy (also re-invoked if `onReady` identity changes). |
### Behavior
- **TV remote wiring**: on mount, if `Platform.isTV`, the module `../app/configureRemoteControl` is `require`d inside a `try/catch`; on failure a warning `'Remote control configuration not available:'` is logged.
- **Font gate**: `!fontsLoaded` → renders `null`; otherwise renders:
```tsx
```
`DarkTheme` comes from `@react-navigation/native`. Element order is significant: `GoBackConfiguration` relies on `useMenuContext`, so it must live under `MenuProvider`.
### Return type
`ReactElement | null` — `null` while fonts are not loaded, otherwise the navigation tree described above.
### Throws
None directly. Descendants such as `useMenuContext` throw if their provider contract is violated.
### Usage
Basic initialization with Expo fonts (as in `apps/expo-multi-tv/App.tsx`):
```tsx
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { AppNavigator } from '@multi-tv/shared-ui';
// side-effect import wires remote keys into react-tv-space-navigation
import '../../packages/shared-ui/src/app/configureRemoteControl';
SplashScreen.preventAutoHideAsync();
export default function App() {
const [loaded, error] = useFonts({
SpaceMono: require('./assets/fonts/SpaceMono-Regular.ttf'),
});
useEffect(() => {
if (loaded || error) SplashScreen.hideAsync();
}, [loaded, error]);
return ;
}
```
With an `onReady` callback (e.g. analytics):
```tsx
{
console.log('Navigation ready');
}}
/>
```
```
--------------------------------
### VideoOverlay component core
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Core implementation of the VideoOverlay component. Uses React.memo and Animated for opacity fade. Returns null when not visible.
```tsx
const VideoOverlay: React.FC = React.memo(({
visible,
paused,
onPlayPause,
onExit,
currentTime,
duration,
isBuffering = false,
}) => {
const opacity = useRef(new Animated.Value(0)).current;
useEffect(() => {
if (visible) {
Animated.timing(opacity, { toValue: 1, duration: 300, useNativeDriver: true }).start();
} else {
Animated.timing(opacity, { toValue: 0, duration: 300, useNativeDriver: true }).start();
}
}, [visible, opacity]);
if (!visible) {
return null;
}
…
});
```
--------------------------------
### Import AppOverrideMediaControlHandler
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Package-internal import used inside VideoHandler.preBufferVideo via dynamic import; not re-exported from @multi-tv/shared-ui.
```ts
import { AppOverrideMediaControlHandler } from '../../utils/AppOverrideMediaControlHandler.kepler';
```
--------------------------------
### Import scaledPixels from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the scaledPixels function from the @multi-tv/shared-ui package.
```typescript
import { scaledPixels } from '@multi-tv/shared-ui';
```
--------------------------------
### Export ExploreScreen and TVScreen from shared-ui index
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Exports the placeholder screens from the shared-ui package's entry point.
```ts
// packages/shared-ui/src/index.ts
export { default as ExploreScreen } from './screens/ExploreScreen';
export { default as TVScreen } from './screens/TVScreen';
```
--------------------------------
### DrawerSyncWrapper helper component
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Private component that captures the drawer navigator reference and opens the drawer when the menu is open.
```tsx
function DrawerSyncWrapper({ drawerNavRef }: { drawerNavRef: React.MutableRefObject }) { … }
```
--------------------------------
### Web key mapping (RemoteControlManager.ts)
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Maps keyboard events to SupportedKeys for web. Uses event.code first, then event.key. Includes GoBack for LG WebOS Magic Remote.
```typescript
const KEY_MAPPING: Record = {
ArrowRight: SupportedKeys.Right,
ArrowLeft: SupportedKeys.Left,
ArrowUp: SupportedKeys.Up,
ArrowDown: SupportedKeys.Down,
Enter: SupportedKeys.Enter,
Backspace: SupportedKeys.Back,
GoBack: SupportedKeys.Back, // For LG WebOS Magic Remote
};
```
--------------------------------
### Run TypeScript type checking
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/README.md
Execute the typecheck script to identify TypeScript errors.
```bash
yarn typecheck
```
--------------------------------
### Import HomeScreen from @multi-tv/shared-ui
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the HomeScreen component for use in an application.
```typescript
import { HomeScreen } from '@multi-tv/shared-ui';
```
--------------------------------
### Import CustomDrawerContent
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Imports the CustomDrawerContent component from the @multi-tv/shared-ui package.
```ts
import { CustomDrawerContent } from '@multi-tv/shared-ui';
```
--------------------------------
### App registration in apps/vega/index.js
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Registers the App component with React Native's AppRegistry. It also ignores all logs via LogBox.ignoreAllLogs().
```js
import { AppRegistry, LogBox } from 'react-native';
import { App } from './src/App';
import { name as appName } from './app.json';
LogBox.ignoreAllLogs();
AppRegistry.registerComponent(appName, () => App);
```
--------------------------------
### Subscribe/Unsubscribe to RemoteControlManager keydown listener
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Pattern from GoBackConfiguration: subscribe to RemoteControlManager.addKeydownListener and remove on cleanup. Handles SupportedKeys.Back to trigger back navigation.
```tsx
import RemoteControlManager from '@multi-tv/shared-ui/src/app/remote-control/RemoteControlManager';
import { SupportedKeys } from '@multi-tv/shared-ui/src/app/remote-control/SupportedKeys';
useEffect(() => {
const remoteControlListener = (pressedKey: SupportedKeys) => {
if (pressedKey === SupportedKeys.Back) {
handleBackPress();
}
};
RemoteControlManager.addKeydownListener(remoteControlListener);
return () => RemoteControlManager.removeKeydownListener(remoteControlListener);
}, [handleBackPress]);
```
--------------------------------
### Default mode integration in VideoHandler.preBufferVideo
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Uses the default mode (false) within the repo's VideoHandler.preBufferVideo. Dynamically imports the handler and sets media control focus with the current video ref.
```ts
const { AppOverrideMediaControlHandler } = await import('./AppOverrideMediaControlHandler.kepler');
await this.videoRef.current.setMediaControlFocus(
componentInstance,
new AppOverrideMediaControlHandler(this.videoRef.current as VideoPlayer, false),
);
```
--------------------------------
### Vega RootStackParamList type declarations
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Declares the param list for the Vega root stack. Route names differ from the shared stack (Main instead of DrawerNavigator) and param shapes do not match the shared screens' expectations, which read title/description/headerImage/movie from route.params.
```ts
export type RootStackParamList = {
Main: undefined;
Details: { itemId: string };
Player: { videoId: string };
};
```
--------------------------------
### Constants: CATALOG_URL and moviesData placeholder
Source: https://github.com/amazonappdev/react-native-multi-tv-app-sample
Module-private constant for the remote catalog endpoint and an exported placeholder array that is not used by HomeScreen.
```ts
const CATALOG_URL = 'https://giolaq.github.io/scrap-tv-feed/catalog.json';
export const moviesData: CardData[] = [];
```