refactor: move view type and drm in source (#3867)

* perf: ensure we do not provide callback to native if no callback provided from app

* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size

* chore: improve issue template

* fix(android): avoid video view flickering at playback startup

* chore(android): refactor DRM props into a dedicated class

* Update android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* chore: fix linter

* fix: ensure drm prop is correctly cleaned

* feat(android): move viewType (secure texture) & drm inside the source

The origianl behavior has been kept for interoperability, but marked as deprecated in doc

* chore: fix linter

* chore(ios): move drm prop in source like on android

* chore: fix linter

* chore: clean log

* fix: allow to disable secure View

* chore: fix viewType resolution (source value was not handled)

* chore: use contentDeepEquals instead of manual checks

* chore: fix linter

* fix: ensure player doesn't start when view is unmounted

* Fix/ensure view drop stop playback startup (#3875)

* fix: ensure player doesn't start when view is unmounted

* chore: revert change

* chore: add warning in case of invalid Surface configuration

* chore: code clean

* fix: simplify surface management

* chore: restore previous code

* chore: fix typo

* chore: code cleanup

* feat(android): add multiDrm flag support

* docs: update docs

* chore: fix ios build

* chore: fix deprecated declaration

---------

Co-authored-by: Krzysztof Moch <krzysmoch.programs@gmail.com>
This commit is contained in:
Olivier Bouillet
2024-07-10 12:17:22 +02:00
committed by GitHub
parent 08f6caa645
commit 66dcf32b56
14 changed files with 141 additions and 99 deletions

View File

@@ -163,6 +163,20 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
)
);
const selectedDrm = source.drm || drm;
const _drm = !selectedDrm
? undefined
: {
type: selectedDrm.type,
licenseServer: selectedDrm.licenseServer,
headers: generateHeaderForNative(selectedDrm.headers),
contentId: selectedDrm.contentId,
certificateUrl: selectedDrm.certificateUrl,
base64Certificate: selectedDrm.base64Certificate,
useExternalGetLicense: !!selectedDrm.getLicense,
multiDrm: selectedDrm.multiDrm,
};
return {
uri,
isNetwork,
@@ -176,26 +190,11 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
cropStart: resolvedSource.cropStart || 0,
cropEnd: resolvedSource.cropEnd,
metadata: resolvedSource.metadata,
drm: _drm,
textTracksAllowChunklessPreparation:
resolvedSource.textTracksAllowChunklessPreparation,
};
}, [source]);
const _drm = useMemo(() => {
if (!drm) {
return;
}
return {
type: drm.type,
licenseServer: drm.licenseServer,
headers: generateHeaderForNative(drm.headers),
contentId: drm.contentId,
certificateUrl: drm.certificateUrl,
base64Certificate: drm.base64Certificate,
useExternalGetLicense: !!drm.getLicense,
};
}, [drm]);
}, [drm, source]);
const _selectedTextTrack = useMemo(() => {
if (!selectedTextTrack) {
@@ -612,7 +611,6 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
ref={nativeRef}
{...rest}
src={src}
drm={_drm}
style={StyleSheet.absoluteFill}
resizeMode={resizeMode}
fullscreen={isFullscreen}

View File

@@ -39,6 +39,7 @@ export type VideoSrc = Readonly<{
cropStart?: Float;
cropEnd?: Float;
metadata?: VideoMetadata;
drm?: Drm;
textTracksAllowChunklessPreparation?: boolean; // android
}>;
@@ -57,6 +58,7 @@ type Drm = Readonly<{
certificateUrl?: string; // ios
base64Certificate?: boolean; // ios default: false
useExternalGetLicense?: boolean; // ios
multiDrm?: boolean; // android
}>;
type TextTracks = ReadonlyArray<
@@ -295,7 +297,6 @@ export type OnControlsVisibilityChange = Readonly<{
export interface VideoNativeProps extends ViewProps {
src?: VideoSrc;
drm?: Drm;
adTagUrl?: string;
allowsExternalPlayback?: boolean; // ios, true
maxBitRate?: Float;

View File

@@ -24,6 +24,7 @@ export type ReactVideoSourceProperties = {
cropStart?: number;
cropEnd?: number;
metadata?: VideoMetadata;
drm?: Drm;
textTracksAllowChunklessPreparation?: boolean;
};
@@ -60,6 +61,7 @@ export type Drm = Readonly<{
contentId?: string; // ios
certificateUrl?: string; // ios
base64Certificate?: boolean; // ios default: false
multiDrm: boolean; // android
/* eslint-disable @typescript-eslint/no-unused-vars */
getLicense?: (
spcBase64: string,
@@ -211,6 +213,7 @@ export type ControlsStyles = {
export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
source?: ReactVideoSource;
/** @deprecated */
drm?: Drm;
style?: StyleProp<ViewStyle>;
adTagUrl?: string;
@@ -258,8 +261,10 @@ export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
textTracks?: TextTracks;
testID?: string;
viewType?: ViewType;
useTextureView?: boolean; // Android // deprecated
useSecureView?: boolean; // Android // deprecated
/** @deprecated */
useTextureView?: boolean; // Android
/** @deprecated */
useSecureView?: boolean; // Android
volume?: number;
localSourceEncryptionKeyScheme?: string;
debug?: DebugConfig;