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
This commit is contained in:
YangJH 2024-03-28 19:22:52 +09:00 committed by GitHub
parent 0312afc8ea
commit 24c1aab3f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -432,9 +432,11 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
[onAspectRatio],
);
const useExternalGetLicense = drm?.getLicense instanceof Function;
const onGetLicense = useCallback(
(event: NativeSyntheticEvent<OnGetLicenseData>) => {
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<VideoRef, ReactVideoProps>(
}
}
},
[drm],
[drm, useExternalGetLicense],
);
useImperativeHandle(
@ -521,7 +523,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
selectedTextTrack={_selectedTextTrack}
selectedAudioTrack={_selectedAudioTrack}
selectedVideoTrack={_selectedVideoTrack}
onGetLicense={onGetLicense}
onGetLicense={useExternalGetLicense ? onGetLicense : undefined}
onVideoLoad={onVideoLoad}
onVideoLoadStart={onVideoLoadStart}
onVideoError={onVideoError}