* 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_EXPORT_VIEW_PROPERTY(onTextTrackDataChanged, RCTDirectEventBlock);
|
||||||
|
|
||||||
RCT_EXTERN_METHOD(seekCmd : (nonnull NSNumber*)reactTag time : (nonnull NSNumber*)time tolerance : (nonnull NSNumber*)tolerance)
|
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(setLicenseResultErrorCmd : (nonnull NSNumber*)reactTag error : (NSString*)error licenseUrl : (NSString*)licenseUrl)
|
||||||
RCT_EXTERN_METHOD(setPlayerPauseStateCmd : (nonnull NSNumber*)reactTag paused : (nonnull BOOL)paused)
|
RCT_EXTERN_METHOD(setPlayerPauseStateCmd : (nonnull NSNumber*)reactTag paused : (nonnull BOOL)paused)
|
||||||
RCT_EXTERN_METHOD(setVolumeCmd : (nonnull NSNumber*)reactTag volume : (nonnull float*)volume)
|
RCT_EXTERN_METHOD(setVolumeCmd : (nonnull NSNumber*)reactTag volume : (nonnull float*)volume)
|
||||||
|
@ -512,7 +512,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
[onControlsVisibilityChange],
|
[onControlsVisibilityChange],
|
||||||
);
|
);
|
||||||
|
|
||||||
const usingExternalGetLicense = drm?.getLicense instanceof Function;
|
const selectedDrm = source?.drm || drm;
|
||||||
|
const usingExternalGetLicense = selectedDrm?.getLicense instanceof Function;
|
||||||
|
|
||||||
const onGetLicense = useCallback(
|
const onGetLicense = useCallback(
|
||||||
async (event: NativeSyntheticEvent<OnGetLicenseData>) => {
|
async (event: NativeSyntheticEvent<OnGetLicenseData>) => {
|
||||||
@ -520,33 +521,43 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const data = event.nativeEvent;
|
const data = event.nativeEvent;
|
||||||
let result;
|
|
||||||
if (data?.spcBase64) {
|
|
||||||
try {
|
try {
|
||||||
|
if (!data?.spcBase64) {
|
||||||
|
throw new Error('No spc received');
|
||||||
|
}
|
||||||
// Handles both scenarios, getLicenseOverride being a promise and not.
|
// Handles both scenarios, getLicenseOverride being a promise and not.
|
||||||
const license = await drm.getLicense(
|
const license = await Promise.resolve(
|
||||||
|
selectedDrm.getLicense(
|
||||||
data.spcBase64,
|
data.spcBase64,
|
||||||
data.contentId,
|
data.contentId,
|
||||||
data.licenseUrl,
|
data.licenseUrl,
|
||||||
data.loadedLicenseUrl,
|
data.loadedLicenseUrl,
|
||||||
);
|
),
|
||||||
result =
|
).catch(() => {
|
||||||
typeof license === 'string' ? license : 'Empty license result';
|
throw new Error('fetch error');
|
||||||
} catch {
|
});
|
||||||
result = 'fetch error';
|
if (typeof license !== 'string') {
|
||||||
}
|
throw Error('Empty license result');
|
||||||
} else {
|
|
||||||
result = 'No spc received';
|
|
||||||
}
|
}
|
||||||
if (nativeRef.current) {
|
if (nativeRef.current) {
|
||||||
NativeVideoManager.setLicenseResultErrorCmd(
|
NativeVideoManager.setLicenseResultCmd(
|
||||||
getReactTag(nativeRef),
|
getReactTag(nativeRef),
|
||||||
result,
|
license,
|
||||||
data.loadedLicenseUrl,
|
data.loadedLicenseUrl,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e instanceof Error ? e.message : 'fetch error';
|
||||||
|
if (nativeRef.current) {
|
||||||
|
NativeVideoManager.setLicenseResultErrorCmd(
|
||||||
|
getReactTag(nativeRef),
|
||||||
|
msg,
|
||||||
|
data.loadedLicenseUrl,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[drm, usingExternalGetLicense],
|
[selectedDrm, usingExternalGetLicense],
|
||||||
);
|
);
|
||||||
|
|
||||||
useImperativeHandle(
|
useImperativeHandle(
|
||||||
|
Loading…
Reference in New Issue
Block a user