UNPKG

unified-video-framework

Version:

Cross-platform video player framework supporting iOS, Android, Web, Smart TVs (Samsung/LG), Roku, and more

35 lines (31 loc) 1.55 kB
import { DRMError, DRMErrorCode } from '../types/DRMTypes'; export class DRMErrorHandler { static getUserFriendlyMessage(error: any): string { 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: any): string { if (!error) return 'Unknown DRM error'; const parts: string[] = []; 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: DRMErrorCode, message: string, details?: any): DRMError { return { code, message, details }; } }