Chore: rework ad props (#4220)

* fix: move ad configuration in source
This commit is contained in:
Olivier Bouillet
2024-10-10 23:53:39 +02:00
committed by GitHub
parent 9a3fcda3b8
commit d86adc52f3
14 changed files with 171 additions and 76 deletions

View File

@@ -91,6 +91,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
useSecureView,
viewType,
shutterColor,
adTagUrl,
adLanguage,
onLoadStart,
onLoad,
onError,
@@ -225,6 +227,12 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
const selectedContentStartTime =
_source.contentStartTime || contentStartTime;
const _ad =
_source.ad ||
(adTagUrl || adLanguage
? {adTagUrl: adTagUrl, adLanguage: adLanguage}
: undefined);
return {
uri,
isNetwork,
@@ -240,6 +248,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
contentStartTime: selectedContentStartTime,
metadata: resolvedSource.metadata,
drm: _drm,
ad: _ad,
cmcd: _cmcd,
textTracks: _textTracks,
textTracksAllowChunklessPreparation:
@@ -247,10 +256,12 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
};
},
[
adLanguage,
adTagUrl,
contentStartTime,
drm,
localSourceEncryptionKeyScheme,
source,
source?.cmcd,
textTracks,
],
);

View File

@@ -26,6 +26,11 @@ type VideoMetadata = Readonly<{
imageUri?: string;
}>;
export type AdsConfig = Readonly<{
adTagUrl?: string;
adLanguage?: string;
}>;
export type VideoSrc = Readonly<{
uri?: string;
isNetwork?: boolean;
@@ -44,6 +49,7 @@ export type VideoSrc = Readonly<{
cmcd?: NativeCmcdConfiguration; // android
textTracksAllowChunklessPreparation?: boolean; // android
textTracks?: TextTracks;
ad?: AdsConfig;
}>;
type DRMType = WithDefault<string, 'widevine'>;
@@ -319,8 +325,6 @@ export type OnControlsVisibilityChange = Readonly<{
export interface VideoNativeProps extends ViewProps {
src?: VideoSrc;
adTagUrl?: string;
adLanguage?: string;
allowsExternalPlayback?: boolean; // ios, true
disableFocus?: boolean; // android
maxBitRate?: Float;

View File

@@ -38,6 +38,7 @@ export type ReactVideoSourceProperties = {
cmcd?: Cmcd; // android
textTracksAllowChunklessPreparation?: boolean;
textTracks?: TextTracks;
ad?: AdConfig;
};
export type ReactVideoSource = Readonly<
@@ -73,6 +74,11 @@ export enum DRMType {
FAIRPLAY = 'fairplay',
}
export type AdConfig = Readonly<{
adTagUrl?: string;
adLanguage?: ISO639_1;
}>;
export type Drm = Readonly<{
type?: DRMType;
licenseServer?: string;
@@ -276,7 +282,9 @@ export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
/** @deprecated Use source.drm */
drm?: Drm;
style?: StyleProp<ViewStyle>;
/** @deprecated Use source.ad.adTagUrl */
adTagUrl?: string;
/** @deprecated Use source.ad.adLanguage */
adLanguage?: ISO639_1;
audioOutput?: AudioOutput; // Mobile
automaticallyWaitsToMinimizeStalling?: boolean; // iOS