Getting started *************** Setup guide for PRESTOplay for React Native. Covers requirements, NPM install, Android, iOS, and web setup, SDK initialization, and first playback with hooks. Prerequisites ============= * React 18.3 or higher * React Native 0.76.9 or higher * iOS 15.1 or higher * Android 8.0 or higher * A Castlabs license key (create one (https://account.castlabs.com/signup)) Note: PRESTOplay for React Native is regularly updated to support the latest stable version of React Native (https://github.com/reactwg/react-native-releases/blob/main/docs/support.md). It's compatible with the interoperability layer of the new bridgeless architecture. Install the SDK =============== npm install --save @castlabs/react-native-prestoplay Android setup ------------- Add the Castlabs repository to "./android/build.gradle". Keep this order of repository declarations for the best build times: allprojects { repositories { google() mavenCentral() maven { url 'https://mvn.players.castlabs.com/' } } } iOS setup --------- Note: PRESTOplay for React Native is distributed as a dynamic library. Static linkage isn't supported. Add the Castlabs repository in "./ios/Podfile": source 'https://github.com/castlabs/Specs.git' Web setup --------- Add the peer dependencies in "package.json": "dependencies": { "react-native-web": "~0.19.6", "@castlabs/prestoplay": "6.36.0", "mux.js": "6.3.0" } Initialize the SDK and start playback ===================================== Call "Sdk.initialize()" (https://players.castlabs.com/react-native/1.4.2/docs/sdk-api/classes/Sdk/#initialize) once at startup with platform-specific license keys. Use the "PlayerProvider" (https://players.castlabs.com/react-native/1.4.2/docs/sdk-api/variables/PlayerProvider/) and "PlayerView" (https://players.castlabs.com/react-native/1.4.2/docs/sdk-api/functions/PlayerView/) components for rendering. import React from "react"; import { Platform, SafeAreaView } from "react-native"; import { Sdk, ContentType, PlayerProvider, PlayerView, } from "@castlabs/react-native-prestoplay"; Sdk.initialize({ licenseKey: Platform.select({ ios: () => (Platform.isTVOS ? "my-tvos-key" : "my-ios-key"), android: () => "my-android-key", web: () => "my-web-key", default: () => { throw new Error(`Unsupported platform: ${Platform.OS}`); }, })(), }); export default function App() { const playerConfig = { autoPlay: true, source: { url: "https://demo.cf.castlabs.com/media/prestohls/master.m3u8", type: ContentType.Hls, }, }; return ( ); } "Sdk.initialize()" must be called before any player component is rendered. The "PlayerProvider" creates and manages the underlying player, and "PlayerView" renders the video surface. Next, see Player basics for the player components and hooks, and Demo application for a complete application you can build and run.