From 24c1aab3f5ab6d2d753199ea16e01c993cc3ef7d Mon Sep 17 00:00:00 2001 From: YangJH Date: Thu, 28 Mar 2024 19:22:52 +0900 Subject: [PATCH] fix: inject onGetLicense prop properly for detect user defined or not (#3608) * fix: inject onGetLicense prop properly for detect user defined or not * fix: fix lint error --- src/Video.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Video.tsx b/src/Video.tsx index fac54d25..490f7678 100644 --- a/src/Video.tsx +++ b/src/Video.tsx @@ -432,9 +432,11 @@ const Video = forwardRef( [onAspectRatio], ); + const useExternalGetLicense = drm?.getLicense instanceof Function; + const onGetLicense = useCallback( (event: NativeSyntheticEvent) => { - if (drm && drm.getLicense instanceof Function) { + if (useExternalGetLicense) { const data = event.nativeEvent; if (data && data.spcBase64) { const getLicenseOverride = drm.getLicense( @@ -479,7 +481,7 @@ const Video = forwardRef( } } }, - [drm], + [drm, useExternalGetLicense], ); useImperativeHandle( @@ -521,7 +523,7 @@ const Video = forwardRef( selectedTextTrack={_selectedTextTrack} selectedAudioTrack={_selectedAudioTrack} selectedVideoTrack={_selectedVideoTrack} - onGetLicense={onGetLicense} + onGetLicense={useExternalGetLicense ? onGetLicense : undefined} onVideoLoad={onVideoLoad} onVideoLoadStart={onVideoLoadStart} onVideoError={onVideoError}