Advanced Usage

Full API reference for the React Native wrapper.


Public Exports

import {
  InkryptVideoPlayerView,            // The component
  type InkPlayerParams,              // Playback parameters
  type InkryptVideoPlayerMethods,    // Ref method interface
} from '@inkrypt/react-native-inkrypt-video-player';
ExportKindPurpose
InkryptVideoPlayerViewComponentRenders the native player
InkPlayerParamstypeDescribes which video to load
InkryptVideoPlayerMethodsinterfaceRef handle methods: play, pause, seek, etc.

Player Properties

Props accepted by InkryptVideoPlayerView. Props are grouped by role - behavior, playback, and layout.


Component Props

PropTypeRequiredDescription
paramsInkPlayerParams | null✅The video to load. null renders an empty player.
volumenumber❌Player volume, 0.0 to 1.0.
playbackSpeednumber❌Playback rate. Accepts 0.5–2.0 in 0.25 steps. Android only.
styleViewStyle❌Standard React Native layout styles.
refMutableRefObject<InkryptVideoPlayerMethods | null>❌Attach to call Player Actions.

volume caveat The volume prop is declared in the TypeScript surface but the native handlers are currently stubbed on both Android and iOS. Setting it will not change the player's actual volume. It is kept in the API for forward compatibility, do not rely on it today.


InkPlayerParams

params describes which video to load and how it should behave on startup. Treat it as immutable per session, mutating the object in place will not re-trigger loading; always create a new object and set it on state.

const [params, setParams] = useState<InkPlayerParams | null>(null);

setParams({
  videoId: 'YOUR_VIDEO_ID',
  otp: 'YOUR_OTP',
  autoPlay: true,
  aspectRatio: 16 / 9,
  tolerateDeveloperMode: false,
});

Fields

FieldTypeRequiredDefaultDescription
videoIdstring✅—The unique video identifier from the Inkrypt Dashboard.
otpstring✅—One-time password used for DRM authentication.
autoPlayboolean❌falseStart playback automatically once the player is ready.
aspectRationumber❌16 / 9Initial aspect ratio used to lay out the player before the video metadata resolves. Prevents layout jumps.
tolerateDeveloperModeboolean❌falseAndroid only. Suppresses the "Developer Mode enabled" block during development.

Platform Notes

  • tolerateDeveloperMode - Android only. On iOS this key is ignored. The native Android SDK blocks playback when Developer Options or USB Debugging are enabled (error codes 9201 / 9202). Set this to true only in development builds - remove it before release.
  • Re-assigning params
    • Android: setting a new params object swaps the active video (setParams() on the native fragment).
    • iOS: the current wrapper initializes the native view once on the first non-null params; subsequent changes are ignored until the component unmounts. If you need to load a different video on iOS, force a remount by keying the view on videoId:
    <InkryptVideoPlayerView key={params?.videoId} params={params} ... />
    

Sizing and Layout

The native player fills whatever frame you give it. There is no intrinsic size, you must apply a style with both a width and either a height or an aspectRatio.

Common patterns:

// Full-width, 16:9 aspect ratio (most common)
<InkryptVideoPlayerView
  style={{ width: '100%', aspectRatio: 16 / 9 }}
  params={params}
/>

// Fixed dimensions
<InkryptVideoPlayerView
  style={{ width: 320, height: 180 }}
  params={params}
/>

// Fill available space inside a flex container
<InkryptVideoPlayerView
  style={{ flex: 1 }}
  params={params}
/>

The aspectRatio field inside params affects the native layout calculation; the aspectRatio inside style is a React Native layout primitive. They serve different purposes, keep them consistent.


Player Actions

Actions are methods you invoke on the player through a ref handle. React components only expose methods via refs, so attach a useRef to the component and call methods through ref.current.


Setup

import { useRef } from 'react';
import {
  InkryptVideoPlayerView,
  type InkryptVideoPlayerMethods,
} from '@inkrypt/react-native-inkrypt-video-player';
function Demo() {
  const playerRef = useRef<InkryptVideoPlayerMethods | null>(null);
  return (
    <InkryptVideoPlayerView
      ref={playerRef as any}
      style={{ width: '100%', aspectRatio: 16 / 9 }}
      params={params}
    />
  );
}

Always null-check ref.current before calling, it is null until the native view mounts:

const methods = playerRef.current; if (methods) { methods.play(); }

Methods

All methods are defined on the InkryptVideoPlayerMethods interface.

MethodSignatureDescriptioniOSAndroid
play() => voidResume playback.✅✅
pause() => voidPause playback.✅✅
seek(position: number) => voidSeek to a position in milliseconds.✅✅
goFullScreen() => voidEnter full-screen mode.⚠️ toggles❌ not wired
resetPlayer() => voidStop playback and clear the loaded video.❌ not wired❌ not wired

Status legend: ✅ works as documented · ⚠️ partial/different behavior · ❌ not wired up in the current native bridge (the JS call is a no-op).


play()

Resumes playback from the current position. No-op if the player is already playing.

playerRef.current?.play();

Maps to:

  • Android - InkPlayerFragment.play()
  • iOS - InkPlayerState.play()

pause()

Pauses playback at the current position.

playerRef.current?.pause();

Maps to:

  • Android - InkPlayerFragment.pause()
  • iOS - InkPlayerState.pausePlayer()

seek(position)

Moves the playback position to the specified point, in milliseconds.

// Jump to 01:15 (75,000 ms)
playerRef.current?.seek(75_000);
PlatformUnderlying callUnit
AndroidInkPlayerSession.seek(position: Long)milliseconds
iOSInkPlayerState.seek(to: Float64)seconds — the wrapper converts internally

goFullScreen()

Requests full-screen mode.

playerRef.current?.goFullScreen();
`

Related native APIs for reference:

- Android - `InkPlayerFragment.toggleFullscreen()` / `enterFullScreen()` / `exitFullScreen()`
- iOS - `InkPlayerState.isFullScreen` (`@Published Bool`)

---

### `resetPlayer()`

Declared on the interface but **not wired up** in the current native bridges. Calling it is a no-op on both platforms.

To reset the player in practice, set `params` back to `null`:

```typescript
setParams(null);

This tears down the native player view. The native SDKs will release the underlying session.


A Note on the Native Split

This wrapper dispatches to two different native implementations:

PlatformNative entrypointDocs
AndroidInkPlayerFragment via InkryptVideoPlayerViewManagernative docs
iOSInkryptVideoPlayerView (SwiftUI) via UIHostingControllernative docs

Behavior is aligned where possible, but some capabilities are platform-specific. Each page calls those out explicitly.

For platform-specific behavior that is not surfaced by this wrapper, consult the native docs linked above.