import { type ViewProps, type HostComponent, codegenNativeCommands, codegenNativeComponent } from 'react-native'; import { type Int32, type Float, type Double, type DirectEventHandler, type WithDefault, } from 'react-native/Libraries/Types/CodegenTypes'; // ============================================================ // Native Props Interface // ============================================================ // Native video metadata interface NativeVideoMetadata { title?: string; subtitle?: string; description?: string; artist?: string; imageUri?: string; } interface NativeStringMapEntry { name: string; value: string; } // Native DRM config (source-embedded DRM) interface NativeSourceDrmConfig { type?: string; licenseServer?: string; headers?: ReadonlyArray>; contentId?: string; certificateUrl?: string; base64Certificate?: boolean; multiDrm?: boolean; localSourceEncryptionKeyScheme?: string; // iOS-Only offline DRM key scheme } // Native CMCD config interface NativeCmcdConfiguration { mode?: Int32; request?: ReadonlyArray>; session?: ReadonlyArray>; object?: ReadonlyArray>; status?: ReadonlyArray>; } // Native text track interface NativeTextTrack { title: string; language: string; type: string; uri: string; } // Native ad config interface NativeAdsConfig { type?: string; streamType?: string; adTagUrl?: string; adLanguage?: string; contentSourceId?: string; videoId?: string; assetKey?: string; format?: string; adTagParameters?: ReadonlyArray>; fallbackUri?: string; } // Native live buffer config interface NativeBufferConfigLive { maxPlaybackSpeed?: Float; minPlaybackSpeed?: Float; maxOffsetMs?: Int32; minOffsetMs?: Int32; targetOffsetMs?: Int32; } // Native source-embedded buffer config interface NativeSourceBufferConfig { minBufferMs?: Int32; maxBufferMs?: Int32; bufferForPlaybackMs?: Int32; bufferForPlaybackAfterRebufferMs?: Int32; backBufferDurationMs?: Int32; cacheSizeMB?: Int32; live?: NativeBufferConfigLive; } interface NativeVideoSource { uri?: string; type?: string; headers?: ReadonlyArray>; startTime?: Double; endTime?: Double; isNetwork?: boolean; isAsset?: boolean; isLocalAssetFile?: boolean; shouldCache?: boolean; mainVer?: Int32; patchVer?: Int32; contentStartTime?: Double; metadata?: NativeVideoMetadata; drm?: NativeSourceDrmConfig; cmcd?: NativeCmcdConfiguration; textTracksAllowChunklessPreparation?: boolean; textTracks?: ReadonlyArray>; ad?: NativeAdsConfig; minLoadRetryCount?: Int32; bufferConfig?: NativeSourceBufferConfig; } interface NativeBufferConfig { minBufferMs?: Int32; maxBufferMs?: Int32; bufferForPlaybackMs?: Int32; bufferForPlaybackAfterRebufferMs?: Int32; backBufferDurationMs?: Int32; cacheSizeMB?: Int32; live?: NativeBufferConfigLive; } interface NativeSelectedTrack { type?: string; value?: string; } interface NativeSelectedVideoTrack { type?: string; value?: Int32; } interface NativeDrmConfig { type?: string; licenseServer?: string; headers?: ReadonlyArray>; contentId?: string; certificateUrl?: string; base64Certificate?: boolean; multiDrm?: boolean; localSourceEncryptionKeyScheme?: string; } export type OnVideoLoadStartEvent = Readonly<{ isNetwork: boolean; type: string; uri: string; }>; export type OnVideoLoadEvent = Readonly<{ currentTime: Double; duration: Double; naturalSize: { width: Double; height: Double; orientation: string; }; }>; export type OnVideoErrorEvent = Readonly<{ error: { code: Int32; domain: string; localizedDescription: string; localizedFailureReason: string; localizedRecoverySuggestion: string; errorString: string; }; }>; export type OnVideoProgressEvent = Readonly<{ currentTime: Double; playableDuration: Double; seekableDuration: Double; }>; export type OnVideoSeekEvent = Readonly<{ currentTime: Double; seekTime: Double; }>; export type OnVideoBufferEvent = Readonly<{ isBuffering: boolean; }>; export type OnVideoBandwidthUpdateEvent = Readonly<{ bitrate: Double; width: Int32; height: Int32; }>; export type OnVideoPlaybackStateChangedEvent = Readonly<{ isPlaying: boolean; isSeeking: boolean; isLooping: boolean; }>; export type OnVideoPlaybackRateChangeEvent = Readonly<{ playbackRate: Float; }>; export type OnVideoVolumeChangeEvent = Readonly<{ volume: Float; }>; export type OnVideoAudioFocusChangedEvent = Readonly<{ hasAudioFocus: boolean; }>; export type OnVideoPictureInPictureStatusChangedEvent = Readonly<{ isActive: boolean; }>; export type OnVideoControlsVisibilityChangeEvent = Readonly<{ isVisible: boolean; }>; export type OnVideoExternalPlaybackChangeEvent = Readonly<{ isExternalPlaybackActive: boolean; }>; export type OnVideoAspectRatioEvent = Readonly<{ width: Double; height: Double; }>; export type TransferEndEvent = Readonly<{ uri: string; bytesTransferred: Double; }>; export interface NativeProps extends ViewProps { // Progress progressUpdateInterval?: Double; // Source source?: NativeVideoSource; // Poster poster?: string; posterResizeMode?: WithDefault; // Playback Control paused?: boolean; muted?: boolean; volume?: Float; rate?: Float; repeat?: boolean; disableAudioFocus?: boolean; playInBackground?: boolean; playWhenInactive?: boolean; automaticallyWaitsToMinimizeStalling?: boolean; shutterColor?: string; // Display resizeMode?: WithDefault; viewType?: WithDefault; useTextureView?: boolean; useSecureView?: boolean; // Buffering bufferConfig?: NativeBufferConfig; minLoadRetryCount?: Int32; maxBitRate?: Int32; preferredForwardBufferDuration?: Double; // Track Selection selectedAudioTrack?: NativeSelectedTrack; selectedTextTrack?: NativeSelectedTrack; selectedVideoTrack?: NativeSelectedVideoTrack; textTracks?: ReadonlyArray>; // DRM drm?: NativeDrmConfig; localSourceEncryptionKeyScheme?: string; // Ads adTagUrl?: string; adLanguage?: string; // Controls controls?: boolean; showNotificationControls?: boolean; disableFocus?: boolean; disableDisconnectError?: boolean; focusable?: boolean; hideShutterView?: boolean; preventsDisplaySleepDuringVideoPlayback?: boolean; // Fullscreen fullscreen?: boolean; fullscreenAutorotate?: boolean; fullscreenOrientation?: WithDefault; // Picture in Picture pictureInPicture?: boolean; // Content contentStartTime?: Double; allowsExternalPlayback?: boolean; audioOutput?: WithDefault; ignoreSilentSwitch?: WithDefault; mixWithOthers?: WithDefault; // Debug enableDebug?: boolean; enableDebugThread?: boolean; // === Events === onVideoLoadStart?: DirectEventHandler; onVideoLoad?: DirectEventHandler; onVideoError?: DirectEventHandler; onVideoProgress?: DirectEventHandler; onVideoSeek?: DirectEventHandler; onVideoEnd?: DirectEventHandler; onVideoBuffer?: DirectEventHandler; onVideoBandwidthUpdate?: DirectEventHandler; onVideoPlaybackStateChanged?: DirectEventHandler; onVideoPlaybackRateChange?: DirectEventHandler; onVideoVolumeChange?: DirectEventHandler; onVideoIdle?: DirectEventHandler; onVideoReadyForDisplay?: DirectEventHandler; onVideoAudioFocusChanged?: DirectEventHandler; onVideoAudioBecomingNoisy?: DirectEventHandler; onVideoFullscreenPlayerWillPresent?: DirectEventHandler; onVideoFullscreenPlayerDidPresent?: DirectEventHandler; onVideoFullscreenPlayerWillDismiss?: DirectEventHandler; onVideoFullscreenPlayerDidDismiss?: DirectEventHandler; onVideoPictureInPictureStatusChanged?: DirectEventHandler; onVideoRestoreUserInterfaceForPictureInPictureStop?: DirectEventHandler; onVideoControlsVisibilityChange?: DirectEventHandler; onVideoExternalPlaybackChange?: DirectEventHandler; onVideoAspectRatio?: DirectEventHandler; onTransferEnd?: DirectEventHandler; } // ============================================================ // Native Commands Interface // ============================================================ export interface NativeCommands { seek: (viewRef: React.ElementRef>, time: Double, tolerance: Double) => void; adjustVolume: (viewRef: React.ElementRef>, volume: Float) => void; setFullScreen: (viewRef: React.ElementRef>, fullscreen: boolean) => void; loadSource: (viewRef: React.ElementRef>, uri: string) => void; pause: (viewRef: React.ElementRef>) => void; resume: (viewRef: React.ElementRef>) => void; enterPictureInPicture: (viewRef: React.ElementRef>) => void; exitPictureInPicture: (viewRef: React.ElementRef>) => void; } export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: [ 'seek', 'adjustVolume', 'setFullScreen', 'loadSource', 'pause', 'resume', 'enterPictureInPicture', 'exitPictureInPicture', ], }); export default codegenNativeComponent('GraniteVideoView');