refactor: internal refactor for prepare new arch (#3980)
* chore(js): fix typo * refactor(js): refactor type code for codegen * refactor(js): refactor Video component - parse shutterColor value within JS - remove internal fullscreen state * chore(js): add deprecation warning comment * fix(js): fix return type * fix(js): fix import path * refactor(android): apply changed API for new arch * refactor(ios): apply changed API for new arch * fix(ios): fix wrong name * refactor: refactor VideoDecoderProperties - rename and add wrapper * refactor(android): Code fixes for backward compatibility with Kotlin
This commit is contained in:
15
src/specs/NativeVideoDecoderInfoModule.ts
Normal file
15
src/specs/NativeVideoDecoderInfoModule.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import {NativeModules} from 'react-native';
|
||||
import type {Int32} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
|
||||
// @TODO rename to "Spec" when applying new arch
|
||||
interface VideoDecoderInfoModuleType {
|
||||
getWidevineLevel: () => Promise<Int32>;
|
||||
isCodecSupported: (
|
||||
mimeType: string,
|
||||
width: Int32,
|
||||
height: Int32,
|
||||
) => Promise<'unsupported' | 'hardware' | 'software'>;
|
||||
isHEVCSupported: () => Promise<'unsupported' | 'hardware' | 'software'>;
|
||||
}
|
||||
|
||||
export default NativeModules.VideoDecoderInfoModule as VideoDecoderInfoModuleType;
|
||||
32
src/specs/NativeVideoManager.ts
Normal file
32
src/specs/NativeVideoManager.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {NativeModules} from 'react-native';
|
||||
import type {
|
||||
Int32,
|
||||
Float,
|
||||
UnsafeObject,
|
||||
} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
|
||||
export type VideoSaveData = {
|
||||
uri: string;
|
||||
};
|
||||
|
||||
// @TODO rename to "Spec" when applying new arch
|
||||
export interface VideoManagerType {
|
||||
seekCmd: (reactTag: Int32, time: Float, tolerance?: Float) => Promise<void>;
|
||||
setPlayerPauseStateCmd: (reactTag: Int32, paused: boolean) => Promise<void>;
|
||||
setLicenseResultCmd: (
|
||||
reactTag: Int32,
|
||||
result: string,
|
||||
licenseUrl: string,
|
||||
) => Promise<void>;
|
||||
setLicenseResultErrorCmd: (
|
||||
reactTag: Int32,
|
||||
error: string,
|
||||
licenseUrl: string,
|
||||
) => Promise<void>;
|
||||
setFullScreenCmd: (reactTag: Int32, fullScreen: boolean) => Promise<void>;
|
||||
setVolumeCmd: (reactTag: Int32, volume: number) => Promise<void>;
|
||||
save: (reactTag: Int32, option: UnsafeObject) => Promise<VideoSaveData>;
|
||||
getCurrentPosition: (reactTag: Int32) => Promise<Int32>;
|
||||
}
|
||||
|
||||
export default NativeModules.VideoManager as VideoManagerType;
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import type {HostComponent, ViewProps} from 'react-native';
|
||||
import {NativeModules, requireNativeComponent} from 'react-native';
|
||||
import {requireNativeComponent} from 'react-native';
|
||||
import type {
|
||||
DirectEventHandler,
|
||||
Double,
|
||||
@@ -91,11 +91,6 @@ type SelectedVideoTrack = Readonly<{
|
||||
value?: string;
|
||||
}>;
|
||||
|
||||
export type Seek = Readonly<{
|
||||
time: Float;
|
||||
tolerance?: Float;
|
||||
}>;
|
||||
|
||||
type BufferConfigLive = Readonly<{
|
||||
maxPlaybackSpeed?: Float;
|
||||
minPlaybackSpeed?: Float;
|
||||
@@ -289,7 +284,7 @@ export type OnAudioFocusChangedData = Readonly<{
|
||||
|
||||
type ControlsStyles = Readonly<{
|
||||
hideSeekBar?: boolean;
|
||||
seekIncrementMS?: number;
|
||||
seekIncrementMS?: Int32;
|
||||
}>;
|
||||
|
||||
export type OnControlsVisibilityChange = Readonly<{
|
||||
@@ -300,10 +295,13 @@ export interface VideoNativeProps extends ViewProps {
|
||||
src?: VideoSrc;
|
||||
adTagUrl?: string;
|
||||
allowsExternalPlayback?: boolean; // ios, true
|
||||
disableFocus?: boolean; // android
|
||||
maxBitRate?: Float;
|
||||
resizeMode?: WithDefault<string, 'none'>;
|
||||
repeat?: boolean;
|
||||
automaticallyWaitsToMinimizeStalling?: boolean;
|
||||
shutterColor?: Int32;
|
||||
audioOutput?: WithDefault<string, 'speaker'>;
|
||||
textTracks?: TextTracks;
|
||||
selectedTextTrack?: SelectedTextTrack;
|
||||
selectedAudioTrack?: SelectedAudioTrack;
|
||||
@@ -375,45 +373,8 @@ export interface VideoNativeProps extends ViewProps {
|
||||
onVideoTracks?: DirectEventHandler<OnVideoTracksData>; // android
|
||||
}
|
||||
|
||||
export type VideoComponentType = HostComponent<VideoNativeProps>;
|
||||
|
||||
export type VideoSaveData = {
|
||||
uri: string;
|
||||
};
|
||||
|
||||
export interface VideoManagerType {
|
||||
save: (option: object, reactTag: number) => Promise<VideoSaveData>;
|
||||
seek: (option: Seek, reactTag: number) => Promise<void>;
|
||||
setPlayerPauseState: (paused: boolean, reactTag: number) => Promise<void>;
|
||||
setLicenseResult: (
|
||||
result: string,
|
||||
licenseUrl: string,
|
||||
reactTag: number,
|
||||
) => Promise<void>;
|
||||
setLicenseResultError: (
|
||||
error: string,
|
||||
licenseUrl: string,
|
||||
reactTag: number,
|
||||
) => Promise<void>;
|
||||
setVolume: (volume: number, reactTag: number) => Promise<void>;
|
||||
getCurrentPosition: (reactTag: number) => Promise<number>;
|
||||
setFullScreen: (fullScreen: boolean, reactTag: number) => Promise<void>;
|
||||
}
|
||||
|
||||
export interface VideoDecoderPropertiesType {
|
||||
getWidevineLevel: () => Promise<number>;
|
||||
isCodecSupported: (
|
||||
mimeType: string,
|
||||
width: number,
|
||||
height: number,
|
||||
) => Promise<'unsupported' | 'hardware' | 'software'>;
|
||||
isHEVCSupported: () => Promise<'unsupported' | 'hardware' | 'software'>;
|
||||
}
|
||||
|
||||
export const VideoManager = NativeModules.VideoManager as VideoManagerType;
|
||||
export const VideoDecoderProperties =
|
||||
NativeModules.VideoDecoderProperties as VideoDecoderPropertiesType;
|
||||
type NativeVideoComponentType = HostComponent<VideoNativeProps>;
|
||||
|
||||
export default requireNativeComponent<VideoNativeProps>(
|
||||
'RCTVideo',
|
||||
) as VideoComponentType;
|
||||
) as NativeVideoComponentType;
|
||||
|
||||
Reference in New Issue
Block a user