This page covers the minimum you need to render the player and play a video. For every available prop and method, see Advanced Usage.
Examples are written as TypeScript functional components. Class components work too - the API surface is identical.
How the Wrapper Works
There are two exports you will use in almost every integration:
| Export | Role |
|---|---|
InkryptVideoPlayerView | A React Native component that renders the native player |
InkPlayerParams | A plain object describing which video to load |
The typical flow is:
1. Render <InkryptVideoPlayerView /> with params = null
↓
2. Build an InkPlayerParams object (videoId + otp) and pass it to `params`
↓
3. Native player (Android fragment / iOS SwiftUI view) loads and starts playback
↓
4. (Optional) Obtain a ref to call play/pause/seek programmatically
Everything else, the controls UI, DRM, buffering, quality selection, chapters, analytics, errors, is owned by the native SDKs and rendered inside the view.
1. Import the Module
import {
InkryptVideoPlayerView,
type InkPlayerParams,
type InkryptVideoPlayerMethods,
} from '@inkrypt/react-native-inkrypt-video-player';
2. Render the Player
Size the view explicitly, the native player fills whatever frame React Native gives it. A common choice is width: '100%' with a 16:9 aspectRatio.
import { useState } from 'react';
import {
InkryptVideoPlayerView,
type InkPlayerParams,
} from '@inkrypt/react-native-inkrypt-video-player';
export default function Demo() {
const [params, setParams] = useState<InkPlayerParams | null>(null);
return (
<InkryptVideoPlayerView
style={{ width: '100%', aspectRatio: 16 / 9 }}
params={params}
/>
);
}
When params is null, the view renders empty. Once you pass an object with a videoId and otp, the native player begins loading.
3. Load a Video
Build an InkPlayerParams and set it on state:
<Pressable
onPress={() => {
setParams({
videoId: 'YOUR_VIDEO_ID',
otp: 'YOUR_OTP',
autoPlay: true,
});
}}
>
<Text>Load Video</Text>
</Pressable>
videoId and otp are provided by the Inkrypt Dashboard, the otp is a short-lived token, so generate it as close to playback time as possible.
Platform note: On Android, re-assigning
paramsafter the first call will load a new video. On iOS, the firstparamsassignment initializes the player and subsequent changes tovideoId/otpare ignored until the component unmounts and remounts. If you need to switch videos on iOS today, unmount and remount the view (e.g. by keying it onvideoId).
4. Control Playback Programmatically (Optional)
To call methods on the player, play, pause, seek, etc., attach a ref:
import { useRef } from 'react';
export default function Demo() {
const [params, setParams] = useState<InkPlayerParams | null>(null);
const playerRef = useRef<InkryptVideoPlayerMethods | null>(null);
return (
<>
<InkryptVideoPlayerView
ref={playerRef as any}
style={{ width: '100%', aspectRatio: 16 / 9 }}
params={params}
/>
<Pressable onPress={() => playerRef.current?.play()}>
<Text>Play</Text>
</Pressable>
<Pressable onPress={() => playerRef.current?.pause()}>
<Text>Pause</Text>
</Pressable>
</>
);
}
For the full list of methods, see Player Actions.
Complete Example
A minimal working app with Video ID / OTP inputs and a load button:
import * as React from 'react';
import CheckBox from '@react-native-community/checkbox';
import Slider from '@react-native-community/slider'
import { Pressable, SafeAreaView, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native';
import { type InkPlayerParams, InkryptVideoPlayerView } from '@inkrypt/react-native-inkrypt-video-player'
export default function App() {
// States for input TextFields: Video ID & OTP
const [videoId, setVideoId] = React.useState('YOUR_VIDEO_ID')
const [otp, setOtp] = React.useState('YOUR_OTP')
const [tolerateDeveloperMode, setTolerateDeveloperMode] = React.useState(false)
const [params, setParams] = React.useState<InkPlayerParams | null>(null)
const [volume, setVolume] = React.useState(1.0)
const playerRef = React.useRef<InkryptVideoPlayerView | null>(null)
return (
<SafeAreaView style={styles.container}>
<ScrollView>
<View style={styles.inputRow}>
<View style={{flex: 1, marginHorizontal: 24}}>
<Text style={styles.label}>Video ID</Text>
<TextInput
style={styles.input}
placeholder="Video ID"
onChangeText={newText => setVideoId(newText)}
defaultValue={videoId}
/>
</View>
<View style={{flex: 1, marginHorizontal: 24}}>
<Text style={styles.label}>OTP</Text>
<TextInput
style={styles.input}
placeholder="OTP"
onChangeText={newText => setOtp(newText)}
defaultValue={otp}
/>
</View>
</View>
<View style={{
...styles.inputRow,
marginHorizontal: 24,
marginVertical: 32
}}>
<CheckBox
tintColors={{
false: '#000000'
}}
disabled={false}
value={tolerateDeveloperMode}
onValueChange={(newValue) => setTolerateDeveloperMode(newValue)}
/>
<Text style={styles.label}>
Tolerate Developer Mode
</Text>
</View>
{
params && <Slider
value={volume}
minimumValue={0.0}
maximumValue={1.0}
onValueChange={(value) => setVolume(value)}
/>
}
<Pressable
style={styles.loadButton}
onPress={() => {
setParams(
{
videoId: videoId,
otp: otp,
autoPlay: false,
aspectRatio: 16 / 9,
tolerateDeveloperMode: tolerateDeveloperMode,
}
)
}}
>
<Text>Load Video</Text>
</Pressable>
<InkryptVideoPlayerView
ref={playerRef}
style={styles.box}
params={params}
volume={volume}
/>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignContent: 'center',
paddingVertical: 24,
},
box: {
width: '100%',
aspectRatio: 16 / 9,
marginVertical: 20,
},
inputRow: {
flexDirection: 'row',
alignItems: 'center'
},
input: {
borderWidth: 1,
marginTop: 12,
color: '#000'
},
label: {
color: '#000'
},
loadButton: {
marginHorizontal: 24,
marginVertical: 12,
padding: 12,
backgroundColor: '#00f',
alignItems: 'center',
}
});