* fix(android): updated getLicense call to work with new syntax, and fixed spelling error (#4014) * fix(android): corrected error with my refactor (#4014) * fix(android): Removed trailing space (#4014) * fix(ios): Refactored following review (#4014) * fix(ios): Lint tidy (#4014) * fix(ios): Removed incorrect semi-colon (#4014) * fix(ios): Fixed more lint errors (#4014) --------- Co-authored-by: Darren Taft <darren.taft@bt.com>
This commit is contained in:
parent
5abfb0d448
commit
2348c5e42c
@ -69,7 +69,7 @@ RCT_EXPORT_VIEW_PROPERTY(onAudioTracks, RCTDirectEventBlock);
|
||||
RCT_EXPORT_VIEW_PROPERTY(onTextTrackDataChanged, RCTDirectEventBlock);
|
||||
|
||||
RCT_EXTERN_METHOD(seekCmd : (nonnull NSNumber*)reactTag time : (nonnull NSNumber*)time tolerance : (nonnull NSNumber*)tolerance)
|
||||
RCT_EXTERN_METHOD(setLicenseResultCmd : (nonnull NSNumber*)reactTag lisence : (NSString*)license licenseUrl : (NSString*)licenseUrl)
|
||||
RCT_EXTERN_METHOD(setLicenseResultCmd : (nonnull NSNumber*)reactTag license : (NSString*)license licenseUrl : (NSString*)licenseUrl)
|
||||
RCT_EXTERN_METHOD(setLicenseResultErrorCmd : (nonnull NSNumber*)reactTag error : (NSString*)error licenseUrl : (NSString*)licenseUrl)
|
||||
RCT_EXTERN_METHOD(setPlayerPauseStateCmd : (nonnull NSNumber*)reactTag paused : (nonnull BOOL)paused)
|
||||
RCT_EXTERN_METHOD(setVolumeCmd : (nonnull NSNumber*)reactTag volume : (nonnull float*)volume)
|
||||
|
@ -512,7 +512,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
[onControlsVisibilityChange],
|
||||
);
|
||||
|
||||
const usingExternalGetLicense = drm?.getLicense instanceof Function;
|
||||
const selectedDrm = source?.drm || drm;
|
||||
const usingExternalGetLicense = selectedDrm?.getLicense instanceof Function;
|
||||
|
||||
const onGetLicense = useCallback(
|
||||
async (event: NativeSyntheticEvent<OnGetLicenseData>) => {
|
||||
@ -520,33 +521,43 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
return;
|
||||
}
|
||||
const data = event.nativeEvent;
|
||||
let result;
|
||||
if (data?.spcBase64) {
|
||||
try {
|
||||
// Handles both scenarios, getLicenseOverride being a promise and not.
|
||||
const license = await drm.getLicense(
|
||||
try {
|
||||
if (!data?.spcBase64) {
|
||||
throw new Error('No spc received');
|
||||
}
|
||||
// Handles both scenarios, getLicenseOverride being a promise and not.
|
||||
const license = await Promise.resolve(
|
||||
selectedDrm.getLicense(
|
||||
data.spcBase64,
|
||||
data.contentId,
|
||||
data.licenseUrl,
|
||||
data.loadedLicenseUrl,
|
||||
);
|
||||
result =
|
||||
typeof license === 'string' ? license : 'Empty license result';
|
||||
} catch {
|
||||
result = 'fetch error';
|
||||
),
|
||||
).catch(() => {
|
||||
throw new Error('fetch error');
|
||||
});
|
||||
if (typeof license !== 'string') {
|
||||
throw Error('Empty license result');
|
||||
}
|
||||
if (nativeRef.current) {
|
||||
NativeVideoManager.setLicenseResultCmd(
|
||||
getReactTag(nativeRef),
|
||||
license,
|
||||
data.loadedLicenseUrl,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : 'fetch error';
|
||||
if (nativeRef.current) {
|
||||
NativeVideoManager.setLicenseResultErrorCmd(
|
||||
getReactTag(nativeRef),
|
||||
msg,
|
||||
data.loadedLicenseUrl,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
result = 'No spc received';
|
||||
}
|
||||
if (nativeRef.current) {
|
||||
NativeVideoManager.setLicenseResultErrorCmd(
|
||||
getReactTag(nativeRef),
|
||||
result,
|
||||
data.loadedLicenseUrl,
|
||||
);
|
||||
}
|
||||
},
|
||||
[drm, usingExternalGetLicense],
|
||||
[selectedDrm, usingExternalGetLicense],
|
||||
);
|
||||
|
||||
useImperativeHandle(
|
||||
|
Loading…
Reference in New Issue
Block a user