/* eslint-disable @typescript-eslint/ban-types */ import type {HostComponent, ViewProps} from 'react-native'; import {requireNativeComponent} from 'react-native'; import type { DirectEventHandler, Double, Float, Int32, WithDefault, } from 'react-native/Libraries/Types/CodegenTypes'; // -------- There are types for native component (future codegen) -------- // if you are looking for types for react component, see src/types/video.ts type Headers = ReadonlyArray< Readonly<{ key: string; value: string; }> >; type VideoMetadata = Readonly<{ title?: string; subtitle?: string; description?: string; imageUri?: string; }>; export type VideoSrc = Readonly<{ uri?: string; isNetwork?: boolean; isAsset?: boolean; shouldCache?: boolean; type?: string; mainVer?: Int32; patchVer?: Int32; requestHeaders?: Headers; startPosition?: Float; cropStart?: Float; cropEnd?: Float; metadata?: VideoMetadata; drm?: Drm; textTracksAllowChunklessPreparation?: boolean; // android }>; type DRMType = WithDefault; type DebugConfig = Readonly<{ enable?: boolean; thread?: boolean; }>; type Drm = Readonly<{ type?: DRMType; licenseServer?: string; headers?: Headers; contentId?: string; // ios certificateUrl?: string; // ios base64Certificate?: boolean; // ios default: false useExternalGetLicense?: boolean; // ios multiDrm?: WithDefault; // android }>; type TextTracks = ReadonlyArray< Readonly<{ title: string; language: string; type: string; uri: string; }> >; type SelectedTextTrackType = WithDefault; type SelectedAudioTrackType = WithDefault; type SelectedTextTrack = Readonly<{ type?: SelectedTextTrackType; value?: string; }>; type SelectedAudioTrack = Readonly<{ type?: SelectedAudioTrackType; value?: string; }>; type SelectedVideoTrackType = WithDefault; type SelectedVideoTrack = Readonly<{ type?: SelectedVideoTrackType; value?: string; }>; type BufferConfigLive = Readonly<{ maxPlaybackSpeed?: Float; minPlaybackSpeed?: Float; maxOffsetMs?: Int32; minOffsetMs?: Int32; targetOffsetMs?: Int32; }>; type BufferingStrategyType = WithDefault; type BufferConfig = Readonly<{ minBufferMs?: Float; maxBufferMs?: Float; bufferForPlaybackMs?: Float; bufferForPlaybackAfterRebufferMs?: Float; maxHeapAllocationPercent?: Float; backBufferDurationMs?: Float; // Android minBackBufferMemoryReservePercent?: Float; minBufferMemoryReservePercent?: Float; cacheSizeMB?: Float; live?: BufferConfigLive; }>; type SubtitleStyle = Readonly<{ fontSize?: Float; paddingTop?: WithDefault; paddingBottom?: WithDefault; paddingLeft?: WithDefault; paddingRight?: WithDefault; opacity?: WithDefault; }>; type OnLoadData = Readonly<{ currentTime: Float; duration: Float; naturalSize: Readonly<{ width: Float; height: Float; orientation: WithDefault; }>; audioTracks: { index: Int32; title?: string; language?: string; bitrate?: Float; type?: string; selected?: boolean; }[]; textTracks: { index: Int32; title?: string; language?: string; /** * iOS only supports VTT, Android supports all 3 */ type?: WithDefault; selected?: boolean; }[]; }>; export type OnLoadStartData = Readonly<{ isNetwork: boolean; type: string; uri: string; }>; export type OnVideoAspectRatioData = Readonly<{ width: Float; height: Float; }>; export type OnBufferData = Readonly<{isBuffering: boolean}>; export type OnProgressData = Readonly<{ currentTime: Float; playableDuration: Float; seekableDuration: Float; }>; export type OnBandwidthUpdateData = Readonly<{ bitrate: Int32; width?: Float; height?: Float; trackId?: Int32; }>; export type OnSeekData = Readonly<{ currentTime: Float; seekTime: Float; }>; export type OnSeekCompleteData = Readonly<{ currentTime: number; seekTime: number; target: number; }>; export type OnPlaybackStateChangedData = Readonly<{ isPlaying: boolean; isSeeking: boolean; }>; export type OnTimedMetadataData = Readonly<{ metadata: { value?: string; identifier: string; }[]; }>; export type OnAudioTracksData = Readonly<{ audioTracks: { index: Int32; title?: string; language?: string; bitrate?: Float; type?: string; selected?: boolean; }[]; }>; type OnTextTracksData = Readonly<{ textTracks: { index: Int32; title?: string; language?: string; /** * iOS only supports VTT, Android supports all 3 */ type?: WithDefault; selected?: boolean; }[]; }>; export type OnTextTrackDataChangedData = Readonly<{ subtitleTracks: string; }>; export type OnVideoTracksData = Readonly<{ videoTracks: { index: Int32; tracksId?: string; codecs?: string; width?: Float; height?: Float; bitrate?: Float; selected?: boolean; }[]; }>; export type OnPlaybackRateChangeData = Readonly<{ playbackRate: Float; }>; export type OnVolumeChangeData = Readonly<{ volume: Float; }>; export type OnExternalPlaybackChangeData = Readonly<{ isExternalPlaybackActive: boolean; }>; export type OnGetLicenseData = Readonly<{ licenseUrl: string; loadedLicenseUrl: string; contentId: string; spcBase64: string; }>; export type OnPictureInPictureStatusChangedData = Readonly<{ isActive: boolean; }>; type OnReceiveAdEventData = Readonly<{ data?: {}; event: WithDefault; }>; export type OnVideoErrorData = Readonly<{ error: Readonly<{ errorString?: string; // android errorException?: string; // android errorStackTrace?: string; // android errorCode?: string; // android error?: string; // ios code?: Int32; // ios localizedDescription?: string; // ios localizedFailureReason?: string; // ios localizedRecoverySuggestion?: string; // ios domain?: string; // ios }>; target?: Int32; // ios }>; export type OnAudioFocusChangedData = Readonly<{ hasAudioFocus: boolean; }>; type ControlsStyles = Readonly<{ hideSeekBar?: boolean; seekIncrementMS?: Int32; }>; export type OnControlsVisibilityChange = Readonly<{ isVisible: boolean; }>; export interface VideoNativeProps extends ViewProps { src?: VideoSrc; adTagUrl?: string; allowsExternalPlayback?: boolean; // ios, true disableFocus?: boolean; // android maxBitRate?: Float; resizeMode?: WithDefault; repeat?: boolean; automaticallyWaitsToMinimizeStalling?: boolean; shutterColor?: Int32; audioOutput?: WithDefault; textTracks?: TextTracks; selectedTextTrack?: SelectedTextTrack; selectedAudioTrack?: SelectedAudioTrack; selectedVideoTrack?: SelectedVideoTrack; // android paused?: boolean; muted?: boolean; controls?: boolean; filter?: WithDefault; filterEnabled?: boolean; volume?: Float; // default 1.0 playInBackground?: boolean; preventsDisplaySleepDuringVideoPlayback?: boolean; preferredForwardBufferDuration?: Float; //ios, 0 playWhenInactive?: boolean; // ios, false pictureInPicture?: boolean; // ios, false ignoreSilentSwitch?: WithDefault; // ios, 'inherit' mixWithOthers?: WithDefault; // ios, 'inherit' rate?: Float; fullscreen?: boolean; // ios, false fullscreenAutorotate?: boolean; fullscreenOrientation?: WithDefault; progressUpdateInterval?: Float; restoreUserInterfaceForPIPStopCompletionHandler?: boolean; localSourceEncryptionKeyScheme?: string; debug?: DebugConfig; showNotificationControls?: WithDefault; // Android, iOS bufferConfig?: BufferConfig; // Android contentStartTime?: Int32; // Android currentPlaybackTime?: Double; // Android disableDisconnectError?: boolean; // Android focusable?: boolean; // Android hideShutterView?: boolean; // Android minLoadRetryCount?: Int32; // Android reportBandwidth?: boolean; //Android subtitleStyle?: SubtitleStyle; // android viewType?: Int32; // Android bufferingStrategy?: BufferingStrategyType; // Android controlsStyles?: ControlsStyles; // Android onControlsVisibilityChange?: DirectEventHandler; onVideoLoad?: DirectEventHandler; onVideoLoadStart?: DirectEventHandler; onVideoAspectRatio?: DirectEventHandler; onVideoBuffer?: DirectEventHandler; onVideoError?: DirectEventHandler; onVideoProgress?: DirectEventHandler; onVideoBandwidthUpdate?: DirectEventHandler; onVideoSeek?: DirectEventHandler; onVideoSeekComplete?: DirectEventHandler; onVideoEnd?: DirectEventHandler<{}>; // all onVideoAudioBecomingNoisy?: DirectEventHandler<{}>; onVideoFullscreenPlayerWillPresent?: DirectEventHandler<{}>; // ios, android onVideoFullscreenPlayerDidPresent?: DirectEventHandler<{}>; // ios, android onVideoFullscreenPlayerWillDismiss?: DirectEventHandler<{}>; // ios, android onVideoFullscreenPlayerDidDismiss?: DirectEventHandler<{}>; // ios, android onReadyForDisplay?: DirectEventHandler<{}>; onPlaybackRateChange?: DirectEventHandler; // all onVolumeChange?: DirectEventHandler; // android, ios onVideoExternalPlaybackChange?: DirectEventHandler; onGetLicense?: DirectEventHandler; onPictureInPictureStatusChanged?: DirectEventHandler; onRestoreUserInterfaceForPictureInPictureStop?: DirectEventHandler<{}>; onReceiveAdEvent?: DirectEventHandler; onVideoPlaybackStateChanged?: DirectEventHandler; // android only onVideoIdle?: DirectEventHandler<{}>; // android only (nowhere in document, so do not use as props. just type declaration) onAudioFocusChanged?: DirectEventHandler; // android only (nowhere in document, so do not use as props. just type declaration) onTimedMetadata?: DirectEventHandler; // ios, android onAudioTracks?: DirectEventHandler; // android onTextTracks?: DirectEventHandler; // android onTextTrackDataChanged?: DirectEventHandler; // iOS onVideoTracks?: DirectEventHandler; // android } type NativeVideoComponentType = HostComponent; export default requireNativeComponent( 'RCTVideo', ) as NativeVideoComponentType;