Skip to main content

BufferConfig

Configuration for video buffering behavior. Allows fine-tuning of buffer sizes and playback parameters for optimal streaming performance.
interface BufferConfig {
  livePlayback?: LivePlaybackParams;
  
  // Android specific
  minBufferMs?: number;
  maxBufferMs?: number;
  bufferForPlaybackMs?: number;
  bufferForPlaybackAfterRebufferMs?: number;
  backBufferDurationMs?: number;
  
  // iOS specific
  preferredForwardBufferDurationMs?: number;
  preferredPeakBitRate?: number;
  preferredMaximumResolution?: Resolution;
  preferredPeakBitRateForExpensiveNetworks?: number;
  preferredMaximumResolutionForExpensiveNetworks?: Resolution;
}

Properties

Cross-Platform

livePlayback
LivePlaybackParams
Configuration for live streaming playback. See LivePlaybackParams below.

Android Properties

minBufferMs
number
default:5000
Minimum duration (in milliseconds) the player will attempt to keep buffered.Platform: Android only
minBufferMs: 5000 // 5 seconds
maxBufferMs
number
default:10000
Maximum duration (in milliseconds) the player will attempt to keep buffered.Platform: Android only
maxBufferMs: 15000 // 15 seconds
bufferForPlaybackMs
number
default:1000
Duration (in milliseconds) of media that must be buffered for playback to start or resume following a user action such as a seek.Platform: Android only
bufferForPlaybackMs: 2000 // 2 seconds
bufferForPlaybackAfterRebufferMs
number
default:2000
Duration (in milliseconds) of media that must be buffered for playback to resume after a rebuffer (stall).Platform: Android only
bufferForPlaybackAfterRebufferMs: 3000 // 3 seconds
backBufferDurationMs
number
Duration (in milliseconds) of media that must be buffered before it can be played from the back buffer.Platform: Android only
backBufferDurationMs: 30000 // 30 seconds

iOS Properties

preferredForwardBufferDurationMs
number
The preferred duration (in milliseconds) of media that the player will attempt to retain in the forward buffer.Platform: iOS, visionOS, tvOS
preferredForwardBufferDurationMs: 10000 // 10 seconds
preferredPeakBitRate
number
The desired limit, in bits per second, of network bandwidth used for loading the current item.Use preferredPeakBitRateForExpensiveNetworks to set a different bit rate when on an expensive network (e.g., cellular).Platform: iOS, visionOS, tvOS
preferredPeakBitRate: 2000000 // 2 Mbps
preferredMaximumResolution
Resolution
The preferred maximum resolution of the video.Use preferredMaximumResolutionForExpensiveNetworks to set a different resolution when on an expensive network (e.g., cellular).Platform: iOS, visionOS, tvOS
preferredMaximumResolution: {
  width: 1920,
  height: 1080
}
preferredPeakBitRateForExpensiveNetworks
number
The desired limit, in bits per second, of network bandwidth used for loading the current item when on an expensive network (e.g., cellular).Platform: iOS, visionOS, tvOS
preferredPeakBitRateForExpensiveNetworks: 1000000 // 1 Mbps on cellular
preferredMaximumResolutionForExpensiveNetworks
Resolution
The preferred maximum resolution of the video when on an expensive network (e.g., cellular).Platform: iOS, visionOS, tvOS
preferredMaximumResolutionForExpensiveNetworks: {
  width: 1280,
  height: 720
}

LivePlaybackParams

Configuration for live streaming playback behavior:
interface LivePlaybackParams {
  minPlaybackSpeed?: number;
  maxPlaybackSpeed?: number;
  maxOffsetMs?: number;
  minOffsetMs?: number;
  targetOffsetMs?: number;
}
minPlaybackSpeed
number
Minimum playback speed for catching up to target live offset.Platform: Android
minPlaybackSpeed: 0.95
maxPlaybackSpeed
number
Maximum playback speed for catching up to target live offset.Platform: Android
maxPlaybackSpeed: 1.05
maxOffsetMs
number
Maximum allowed live offset. The player won’t exceed this limit.Platform: Android
maxOffsetMs: 10000 // 10 seconds
minOffsetMs
number
Minimum allowed live offset. The player won’t go below this limit.Platform: Android
minOffsetMs: 2000 // 2 seconds
targetOffsetMs
number
Target live offset. The player will try to maintain this offset from the live edge.Platform: Android, iOS, visionOS, tvOS
targetOffsetMs: 5000 // 5 seconds behind live

Resolution

Video resolution specification:
interface Resolution {
  width: number;
  height: number;
}
width
number
required
Width in pixels
height
number
required
Height in pixels

Examples

Android Buffer Configuration

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/video.mp4',
  bufferConfig: {
    minBufferMs: 10000,      // 10 seconds minimum buffer
    maxBufferMs: 30000,      // 30 seconds maximum buffer
    bufferForPlaybackMs: 2500,
    bufferForPlaybackAfterRebufferMs: 5000,
    backBufferDurationMs: 60000  // Keep 60 seconds of back buffer
  }
};

iOS Buffer Configuration

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/video.m3u8',
  bufferConfig: {
    preferredForwardBufferDurationMs: 15000,
    preferredPeakBitRate: 3000000,  // 3 Mbps on WiFi
    preferredMaximumResolution: {
      width: 1920,
      height: 1080
    },
    // Lower quality on cellular
    preferredPeakBitRateForExpensiveNetworks: 1000000,  // 1 Mbps
    preferredMaximumResolutionForExpensiveNetworks: {
      width: 1280,
      height: 720
    }
  }
};

Live Streaming Configuration

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/live/stream.m3u8',
  bufferConfig: {
    livePlayback: {
      targetOffsetMs: 3000,      // Stay 3 seconds behind live
      minOffsetMs: 1000,         // Don't go closer than 1 second
      maxOffsetMs: 10000,        // Don't fall more than 10 seconds behind
      minPlaybackSpeed: 0.95,    // Slow down to at most 0.95x
      maxPlaybackSpeed: 1.1      // Speed up to at most 1.1x
    }
  }
};

Adaptive Quality Based on Network

import { VideoConfig } from 'react-native-video';

const config: VideoConfig = {
  uri: 'https://example.com/video.m3u8',
  bufferConfig: {
    // High quality on WiFi
    preferredPeakBitRate: 5000000,  // 5 Mbps
    preferredMaximumResolution: {
      width: 3840,
      height: 2160  // 4K
    },
    
    // Reduced quality on cellular to save data
    preferredPeakBitRateForExpensiveNetworks: 800000,  // 800 Kbps
    preferredMaximumResolutionForExpensiveNetworks: {
      width: 854,
      height: 480  // SD
    }
  }
};

Platform Support

PropertyAndroidiOSvisionOStvOS
livePlayback.targetOffsetMs
livePlayback.minPlaybackSpeed---
livePlayback.maxPlaybackSpeed---
livePlayback.maxOffsetMs---
livePlayback.minOffsetMs---
minBufferMs---
maxBufferMs---
bufferForPlaybackMs---
bufferForPlaybackAfterRebufferMs---
backBufferDurationMs---
preferredForwardBufferDurationMs-
preferredPeakBitRate-
preferredMaximumResolution-
preferredPeakBitRateForExpensiveNetworks-
preferredMaximumResolutionForExpensiveNetworks-
  • VideoConfig - Main video configuration type that includes buffer configuration

Build docs developers (and LLMs) love