perf: ensure we do not provide callback to native if no callback provided from app (#3735)
* perf: ensure we do not provide callback to native if no callback provided from app * perf: remove onIdle Callback * chore: code review
This commit is contained in:
parent
8eb31e82c7
commit
c59d00a0f0
@ -1252,6 +1252,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
// When timeMetadata is read the event onTimedMetadata is triggered
|
||||
func handleTimeMetadataChange(timedMetadata: [AVMetadataItem]) {
|
||||
guard onTimedMetadata != nil else { return }
|
||||
var metadata: [[String: String?]?] = []
|
||||
for item in timedMetadata {
|
||||
let value = item.value as? String
|
||||
@ -1510,6 +1511,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
@objc
|
||||
func handleAVPlayerAccess(notification: NSNotification!) {
|
||||
guard onVideoBandwidthUpdate != nil else { return }
|
||||
guard let accessLog = (notification.object as? AVPlayerItem)?.accessLog() else {
|
||||
return
|
||||
}
|
||||
|
@ -339,10 +339,6 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
);
|
||||
|
||||
// android only
|
||||
const onVideoIdle = useCallback(() => {
|
||||
onIdle?.();
|
||||
}, [onIdle]);
|
||||
|
||||
const _onTimedMetadata = useCallback(
|
||||
(e: NativeSyntheticEvent<OnTimedMetadataData>) => {
|
||||
onTimedMetadata?.(e.nativeEvent);
|
||||
@ -542,38 +538,62 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
selectedAudioTrack={_selectedAudioTrack}
|
||||
selectedVideoTrack={_selectedVideoTrack}
|
||||
onGetLicense={useExternalGetLicense ? onGetLicense : undefined}
|
||||
onVideoLoad={onVideoLoad as (e: NativeSyntheticEvent<object>) => void}
|
||||
onVideoLoadStart={onVideoLoadStart}
|
||||
onVideoError={onVideoError}
|
||||
onVideoProgress={onVideoProgress}
|
||||
onVideoSeek={onVideoSeek}
|
||||
onVideoLoad={
|
||||
onLoad || hasPoster
|
||||
? (onVideoLoad as (e: NativeSyntheticEvent<object>) => void)
|
||||
: undefined
|
||||
}
|
||||
onVideoLoadStart={
|
||||
onLoadStart || hasPoster ? onVideoLoadStart : undefined
|
||||
}
|
||||
onVideoError={onError ? onVideoError : undefined}
|
||||
onVideoProgress={onProgress ? onVideoProgress : undefined}
|
||||
onVideoSeek={onSeek ? onVideoSeek : undefined}
|
||||
onVideoEnd={onEnd}
|
||||
onVideoBuffer={onVideoBuffer}
|
||||
onVideoPlaybackStateChanged={onVideoPlaybackStateChanged}
|
||||
onVideoBandwidthUpdate={_onBandwidthUpdate}
|
||||
onTimedMetadata={_onTimedMetadata}
|
||||
onAudioTracks={_onAudioTracks}
|
||||
onTextTracks={_onTextTracks}
|
||||
onTextTrackDataChanged={_onTextTrackDataChanged}
|
||||
onVideoTracks={_onVideoTracks}
|
||||
onVideoBuffer={onBuffer ? onVideoBuffer : undefined}
|
||||
onVideoPlaybackStateChanged={
|
||||
onPlaybackRateChange ? onVideoPlaybackStateChanged : undefined
|
||||
}
|
||||
onVideoBandwidthUpdate={
|
||||
onBandwidthUpdate ? _onBandwidthUpdate : undefined
|
||||
}
|
||||
onTimedMetadata={onTimedMetadata ? _onTimedMetadata : undefined}
|
||||
onAudioTracks={onAudioTracks ? _onAudioTracks : undefined}
|
||||
onTextTracks={onTextTracks ? _onTextTracks : undefined}
|
||||
onTextTrackDataChanged={
|
||||
onTextTrackDataChanged ? _onTextTrackDataChanged : undefined
|
||||
}
|
||||
onVideoTracks={onVideoTracks ? _onVideoTracks : undefined}
|
||||
onVideoFullscreenPlayerDidDismiss={onFullscreenPlayerDidDismiss}
|
||||
onVideoFullscreenPlayerDidPresent={onFullscreenPlayerDidPresent}
|
||||
onVideoFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}
|
||||
onVideoFullscreenPlayerWillPresent={onFullscreenPlayerWillPresent}
|
||||
onVideoExternalPlaybackChange={onVideoExternalPlaybackChange}
|
||||
onVideoIdle={onVideoIdle}
|
||||
onAudioFocusChanged={_onAudioFocusChanged}
|
||||
onReadyForDisplay={_onReadyForDisplay}
|
||||
onPlaybackRateChange={_onPlaybackRateChange}
|
||||
onVolumeChange={_onVolumeChange}
|
||||
onVideoExternalPlaybackChange={
|
||||
onExternalPlaybackChange ? onVideoExternalPlaybackChange : undefined
|
||||
}
|
||||
onVideoIdle={onIdle}
|
||||
onAudioFocusChanged={
|
||||
onAudioFocusChanged ? _onAudioFocusChanged : undefined
|
||||
}
|
||||
onReadyForDisplay={onReadyForDisplay ? _onReadyForDisplay : undefined}
|
||||
onPlaybackRateChange={
|
||||
onPlaybackRateChange ? _onPlaybackRateChange : undefined
|
||||
}
|
||||
onVolumeChange={onVolumeChange ? _onVolumeChange : undefined}
|
||||
onVideoAudioBecomingNoisy={onAudioBecomingNoisy}
|
||||
onPictureInPictureStatusChanged={_onPictureInPictureStatusChanged}
|
||||
onPictureInPictureStatusChanged={
|
||||
onPictureInPictureStatusChanged
|
||||
? _onPictureInPictureStatusChanged
|
||||
: undefined
|
||||
}
|
||||
onRestoreUserInterfaceForPictureInPictureStop={
|
||||
onRestoreUserInterfaceForPictureInPictureStop
|
||||
}
|
||||
onVideoAspectRatio={_onVideoAspectRatio}
|
||||
onVideoAspectRatio={onAspectRatio ? _onVideoAspectRatio : undefined}
|
||||
onReceiveAdEvent={
|
||||
_onReceiveAdEvent as (e: NativeSyntheticEvent<object>) => void
|
||||
onReceiveAdEvent
|
||||
? (_onReceiveAdEvent as (e: NativeSyntheticEvent<object>) => void)
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
{hasPoster && showPoster ? (
|
||||
|
Loading…
Reference in New Issue
Block a user