feat(android): make buffering strategy dynamic (#3756)

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size
* feat: expose bufferingStrategy to app and change default behavior
rename disableBuffering undocumented prop to bufferingStrategy and document it.
before this change, default was 'dependingOnMemory'. It can trigger some unnecessary gc() call on android.
This commit is contained in:
Olivier Bouillet
2024-05-11 22:02:04 +02:00
committed by GitHub
parent 1a48f190f0
commit e420418e8f
7 changed files with 105 additions and 31 deletions

View File

@@ -93,6 +93,8 @@ export type Seek = Readonly<{
tolerance?: Float;
}>;
type BufferingStrategyType = WithDefault<string, 'Default'>;
type BufferConfig = Readonly<{
minBufferMs?: Float;
maxBufferMs?: Float;
@@ -317,6 +319,7 @@ export interface VideoNativeProps extends ViewProps {
subtitleStyle?: SubtitleStyle; // android
useTextureView?: boolean; // Android
useSecureView?: boolean; // Android
bufferingStrategy?: BufferingStrategyType; // Android
onVideoLoad?: DirectEventHandler<OnLoadData>;
onVideoLoadStart?: DirectEventHandler<OnLoadStartData>;
onVideoAspectRatio?: DirectEventHandler<OnVideoAspectRatioData>;

View File

@@ -68,6 +68,12 @@ export type Drm = Readonly<{
/* eslint-enable @typescript-eslint/no-unused-vars */
}>;
export enum BufferingStrategyType {
DEFAULT = 'Default',
DISABLE_BUFFERING = 'DisableBuffering',
DEPENDING_ON_MEMORY = 'DependingOnMemory',
}
export type BufferConfig = {
minBufferMs?: number;
maxBufferMs?: number;
@@ -195,6 +201,7 @@ export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
audioOutput?: AudioOutput; // Mobile
automaticallyWaitsToMinimizeStalling?: boolean; // iOS
bufferConfig?: BufferConfig; // Android
bufferingStrategy?: BufferingStrategyType;
chapters?: Chapters[]; // iOS
contentStartTime?: number; // Android
controls?: boolean;