unified-video-framework
Version:
Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more
36 lines • 1.66 kB
JavaScript
import { DRMErrorCode } from '../types/DRMTypes.js';
export class DRMErrorHandler {
static getUserFriendlyMessage(error) {
const code = error?.code || '';
switch (code) {
case DRMErrorCode.UNSUPPORTED:
return 'Your browser does not support the required DRM system for this content.';
case DRMErrorCode.LICENSE_REQUEST_FAILED:
return 'Unable to obtain a license for this content. Please try again later.';
case DRMErrorCode.CERTIFICATE_FETCH_FAILED:
return 'Unable to verify content protection. Please try again later.';
case DRMErrorCode.OUTPUT_RESTRICTED:
return 'Content playback is restricted on this display. Try using a different monitor or disabling external displays.';
case DRMErrorCode.KEY_SESSION_ERROR:
return 'A content protection error occurred. Please refresh the page and try again.';
default:
return 'An error occurred with content protection. Please try again.';
}
}
static getTechnicalMessage(error) {
if (!error)
return 'Unknown DRM error';
const parts = [];
if (error.code)
parts.push(`Code: ${error.code}`);
if (error.message)
parts.push(`Message: ${error.message}`);
if (error.details)
parts.push(`Details: ${JSON.stringify(error.details)}`);
return parts.join(' | ') || 'Unknown DRM error';
}
static createError(code, message, details) {
return { code, message, details };
}
}
//# sourceMappingURL=DRMErrorHandler.js.map