feat(android): add onControlsVisiblityChange
(#3925)
* Adding onControlsVisiblityChange for Android
This commit is contained in:
@@ -22,6 +22,7 @@ import NativeVideoComponent, {
|
||||
type OnAudioTracksData,
|
||||
type OnBandwidthUpdateData,
|
||||
type OnBufferData,
|
||||
type OnControlsVisibilityChange,
|
||||
type OnExternalPlaybackChangeData,
|
||||
type OnGetLicenseData,
|
||||
type OnLoadStartData,
|
||||
@@ -91,6 +92,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
onEnd,
|
||||
onBuffer,
|
||||
onBandwidthUpdate,
|
||||
onControlsVisibilityChange,
|
||||
onExternalPlaybackChange,
|
||||
onFullscreenPlayerWillPresent,
|
||||
onFullscreenPlayerDidPresent,
|
||||
@@ -482,6 +484,13 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
[onAspectRatio],
|
||||
);
|
||||
|
||||
const _onControlsVisibilityChange = useCallback(
|
||||
(e: NativeSyntheticEvent<OnControlsVisibilityChange>) => {
|
||||
onControlsVisibilityChange?.(e.nativeEvent);
|
||||
},
|
||||
[onControlsVisibilityChange],
|
||||
);
|
||||
|
||||
const useExternalGetLicense = drm?.getLicense instanceof Function;
|
||||
|
||||
const onGetLicense = useCallback(
|
||||
@@ -639,6 +648,9 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
? (_onReceiveAdEvent as (e: NativeSyntheticEvent<object>) => void)
|
||||
: undefined
|
||||
}
|
||||
onControlsVisibilityChange={
|
||||
onControlsVisibilityChange ? _onControlsVisibilityChange : undefined
|
||||
}
|
||||
/>
|
||||
{hasPoster && showPoster ? (
|
||||
<Image style={posterStyle} source={{uri: poster}} />
|
||||
|
@@ -289,6 +289,10 @@ type ControlsStyles = Readonly<{
|
||||
seekIncrementMS?: number;
|
||||
}>;
|
||||
|
||||
export type OnControlsVisibilityChange = Readonly<{
|
||||
isVisible: boolean;
|
||||
}>;
|
||||
|
||||
export interface VideoNativeProps extends ViewProps {
|
||||
src?: VideoSrc;
|
||||
drm?: Drm;
|
||||
@@ -337,6 +341,7 @@ export interface VideoNativeProps extends ViewProps {
|
||||
useSecureView?: boolean; // Android
|
||||
bufferingStrategy?: BufferingStrategyType; // Android
|
||||
controlsStyles?: ControlsStyles; // Android
|
||||
onControlsVisibilityChange?: DirectEventHandler<OnControlsVisibilityChange>;
|
||||
onVideoLoad?: DirectEventHandler<OnLoadData>;
|
||||
onVideoLoadStart?: DirectEventHandler<OnLoadStartData>;
|
||||
onVideoAspectRatio?: DirectEventHandler<OnVideoAspectRatioData>;
|
||||
|
@@ -4,6 +4,7 @@ import type {
|
||||
OnAudioTracksData,
|
||||
OnBandwidthUpdateData,
|
||||
OnBufferData,
|
||||
OnControlsVisibilityChange,
|
||||
OnExternalPlaybackChangeData,
|
||||
OnLoadStartData,
|
||||
OnPictureInPictureStatusChangedData,
|
||||
@@ -237,6 +238,7 @@ export interface ReactVideoEvents {
|
||||
onIdle?: () => void; // Android
|
||||
onBandwidthUpdate?: (e: OnBandwidthUpdateData) => void; //Android
|
||||
onBuffer?: (e: OnBufferData) => void; //Android, iOS
|
||||
onControlsVisibilityChange?: (e: OnControlsVisibilityChange) => void; // Android, iOS
|
||||
onEnd?: () => void; //All
|
||||
onError?: (e: OnVideoErrorData) => void; //Android, iOS
|
||||
onExternalPlaybackChange?: (e: OnExternalPlaybackChangeData) => void; //iOS
|
||||
|
Reference in New Issue
Block a user