This reference covers the full Dart API of the Inkrypt Video Player Flutter SDK — widget configuration, controller methods, data types, and platform-specific notes.
InkPlayerParams
Configuration object that specifies which video to load and how to play it.
Constructor
const InkPlayerParams({
required String videoId,
required String otp,
bool autoPlay = false,
double aspectRatio = 16 / 9,
bool tolerateDeveloperMode = false,
})
Properties
| Property | Type | Default | Platform | Description |
|---|---|---|---|---|
videoId | String | required | All | Unique identifier for the video (from the InkryptVideos dashboard) |
otp | String | required | All | One-time password for DRM authentication |
autoPlay | bool | false | All | Start playback automatically once the video is loaded |
aspectRatio | double | 16 / 9 | All | Width-to-height ratio of the player frame. Must be greater than 0 |
tolerateDeveloperMode | bool | false | Android only | If true, the SDK allows playback when Android developer mode is enabled on the device. Silently ignored on iOS |
Example
InkPlayerParams(
videoId: 'abc123',
otp: 'your-otp-token',
autoPlay: true,
aspectRatio: 16 / 9,
tolerateDeveloperMode: false, // Android only
)
InkryptVideoPlayer Widget
The Flutter widget that embeds the native video player view.
Constructor
const InkryptVideoPlayer({
Key? key,
InkPlayerParams? initialParams,
required void Function(InkryptVideoPlayerController) onPlayerCreated,
})
Parameters
onPlayerCreated (required)
onPlayerCreated (required)Type: FutureOr<void> Function(InkryptVideoPlayerController)
Called once when the native player view is ready. Provides the controller instance used to interact with the player.
InkryptVideoPlayer(
onPlayerCreated: (controller) {
_controller = controller;
},
),
initialParams (optional)
initialParams (optional)Type: InkPlayerParams?
If provided, the player loads this video immediately when the native view is ready. Equivalent to calling setParams(initialParams) inside onPlayerCreated.
InkryptVideoPlayer(
initialParams: InkPlayerParams(
videoId: 'abc123',
otp: 'your-otp',
autoPlay: true,
),
onPlayerCreated: (controller) {
_controller = controller;
},
),
Layout Behavior
The widget fills the full available width and constrains its height based on InkPlayerParams.aspectRatio (default 16/9). It renders with a black background. The aspect ratio can only be set at load time via InkPlayerParams, it cannot be changed independently after the player is created.
Platform Notes
- Android: Uses
PlatformViewLinkwithinitExpensiveAndroidViewto embed the native view. This approach ensures correct sizing and touch handling. - iOS: Uses
UiKitViewwithEagerGestureRecognizer, which allows the native seek slider inside the player to capture gestures correctly.
InkryptVideoPlayerController
Abstract class that bridges Dart to the native player. All methods are async and communicate via a MethodChannel.
You never instantiate this directly, you receive it through InkryptVideoPlayer.onPlayerCreated.
Video Loading
setParams(InkPlayerParams params) → Future<void>
setParams(InkPlayerParams params) → Future<void>Load a video into the player (or reload with new params). If a video is already playing, it stops and the new video begins loading.
await _controller.setParams(
InkPlayerParams(
videoId: 'abc123',
otp: 'your-otp',
autoPlay: true,
),
);
aspectRatio must be greater than 0, throws ArgumentError otherwise.
currentParams → Future<InkPlayerParams?>
currentParams → Future<InkPlayerParams?>Returns the params most recently passed to setParams, or null if no video has been loaded.
final params = await _controller.currentParams;
print('Currently loaded: ${params?.videoId}');
Playback Control
play() → Future<void>
play() → Future<void>Resume or start playback.
await _controller.play();
pause() → Future<void>
pause() → Future<void>Pause playback.
await _controller.pause();
seek(int position) → Future<void>
seek(int position) → Future<void>Seek to a specific position. position is in milliseconds.
// Seek to 1 minute 30 seconds
await _controller.seek(90000);
resetPlayer() → Future<void>
resetPlayer() → Future<void>Stop playback and unload the current video, returning the player to its idle state.
await _controller.resetPlayer();
Playback State
isPlaying → Future<bool>
isPlaying → Future<bool>Returns true if the player is actively playing (not paused, not buffering).
final playing = await _controller.isPlaying;
videoLength → Future<num?>
videoLength → Future<num?>Returns the total duration of the loaded video in seconds. Returns null if no video is loaded or duration is not yet available.
final duration = await _controller.videoLength;
// e.g. 3600.0 (1 hour)
currentPosition → Future<num?>
currentPosition → Future<num?>Returns the current playback position in milliseconds. Returns null if no video is loaded.
final positionMs = await _controller.currentPosition;
// e.g. 45000 (45 seconds in)
currentChapter → Future<VideoChapter?>
currentChapter → Future<VideoChapter?>Returns the VideoChapter active at the current playback position, or null if the video has no chapters or chapters are not yet loaded.
final chapter = await _controller.currentChapter;
if (chapter != null) {
print('Now in chapter: ${chapter.title}');
}
playerState → Future<PlayerState>
playerState → Future<PlayerState>Fetches all four state values in parallel and returns them as a single PlayerState object. More efficient than calling each getter individually when you need multiple values at once.
final state = await _controller.playerState;
print('Playing: ${state.isPlaying}');
print('Position: ${state.currentPosition}ms');
print('Duration: ${state.videoLength}s');
print('Chapter: ${state.currentChapter?.title}');
Audio and Speed
setVolume(double volume) → Future<void>
setVolume(double volume) → Future<void>Set the player volume. Valid range is 0.0 (muted) to 1.0 (full volume).
await _controller.setVolume(0.5); // 50%
await _controller.setVolume(0.0); // Mute
await _controller.setVolume(1.0); // Full volume
setPlaybackSpeed(double rate) → Future<void>
setPlaybackSpeed(double rate) → Future<void>Set the playback speed multiplier.
Accepted values: 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0
await _controller.setPlaybackSpeed(1.5); // 1.5× speed
await _controller.setPlaybackSpeed(1.0); // Normal speed
Display
goFullScreen() → Future<void>
goFullScreen() → Future<void>Trigger the native full-screen transition. The player handles orientation locking and the UI transition automatically.
await _controller.goFullScreen();
PlayerState
A snapshot of the player's current state, returned by controller.playerState.
Properties
| Property | Type | Unit | Description |
|---|---|---|---|
isPlaying | bool | — | true if the player is actively playing |
videoLength | num? | seconds | Total video duration. null if not yet available |
currentPosition | num? | milliseconds | Current playback position. null if not yet available |
currentChapter | VideoChapter? | — | Active chapter at the current position. null if none |
Example
final state = await _controller.playerState;
final positionSec = (state.currentPosition ?? 0) / 1000;
final durationSec = state.videoLength ?? 0;
print('${positionSec.toStringAsFixed(0)}s / ${durationSec.toStringAsFixed(0)}s');
print('Chapter: ${state.currentChapter?.title ?? "none"}');
VideoChapter
Represents a named chapter within a video.
Properties
| Property | Type | Unit | Description |
|---|---|---|---|
title | String | — | The chapter name |
start | int | milliseconds | Chapter start time |
Example
final chapter = await _controller.currentChapter;
if (chapter != null) {
final startSec = chapter.start / 1000;
print('Chapter: ${chapter.title}, starts at ${startSec.toStringAsFixed(0)}s');
}
InkryptPlayerError
Represents a playback error received from the native layer.
Properties
| Property | Type | Description |
|---|---|---|
code | int? | Numeric error code from the license server. null for most errors |
message | String? | Human-readable error description |
For a complete list of error messages and recovery strategies, see the Errors Guide.
Mapping Flutter API to Native SDK
The Flutter SDK wraps the native SDKs via method channels. The table below maps Flutter controller methods to their native equivalents for reference when consulting the native documentation.
Flutter (InkryptVideoPlayerController) | iOS (InkPlayerState) | Android |
|---|---|---|
play() | play() | play() |
pause() | pausePlayer() | pause() |
seek(int ms) | seek(to: Float64 seconds) | seek(Long ms) |
resetPlayer() | reset() | resetPlayer() |
setVolume(double) | volume: Float | setVolume(float) |
setPlaybackSpeed(double) | selectedRate: Float | setPlaybackSpeed(float) |
goFullScreen() | isFullScreen = true | goFullScreen() |
isPlaying | isPlaying: Bool | isPlaying |
videoLength (seconds) | videoLength: CMTime? | videoLength |
currentPosition (ms) | seekDuration: Float64 (seconds) | currentPosition (ms) |
currentChapter | currentChapter: VideoChapter? | currentChapter |
Seek unit difference: The Flutter
seek()method takes milliseconds. The native iOSseek(to:)takes seconds. The Flutter SDK handles the conversion internally.