How videojs/videojs-contrib-eme works
Main Components
• Video.js Player Integration – The entry point where the plugin is initialized by the user on a Video.js player.
• Plugin Initialization & API Interface – Represented by “plugin.js”, this component exposes methods such as player.eme(), initializeMediaKeys(), detectSupportedCDMs(), and initLegacyFairplay().
• DRM Modules – Group together individual modules handling various DRM systems:
• EME & CDM Utilities – “cdm.js” and “eme.js” provide general purpose functionality for managing MediaKeys and EME events.
• FairPlay Support – “fairplay.js” handles certificate fetching and license requests specifically for Apple’s FairPlay.
• PlayReady Support – “playready.js” (and “ms-prefixed.js” for Microsoft-specific extensions) manage PlayReady license retrieval and key handling.
• HTTP Request Handling – “http-handler.js” centralizes network calls to fetch licenses and certificates.
• Constants & Error Handling – “consts/errors.js” supplies standardized error messages and configuration constants.
• Utility Functions – “utils.js” includes helper methods for various common tasks.
• Testing & Build Infrastructure – Although secondary in the production architecture, show the test suite (“test” directory) for unit testing each module and the configuration/build scripts (e.g., “rollup.config.js”, “karma.conf.js” and other project-level configs). This reinforces that the plugin is built, bundled, and maintained with CI/CD integration.
Relationships & Interactions
• Each DRM module (e.g., fairplay.js, playready.js) should be shown interacting with the HTTP Handler (http-handler.js) for retrieving licenses/certificates, as well as relying on the general utilities (utils.js, constants/error definitions).
• A network component (an external “License Server”/ “Certificate Server”) to indicate that HTTP calls are made externally.
Architectural Patterns & Technologies
• Plugin Pattern – The design is plug-in based for Video.js, allowing easy extension or overriding of default behaviors.
• Use of Configuration Files – Mention that build scripts (rollup.config.js, karma.conf.js) indicate a bundling process which is a key element in maintaining cross-platform compatibility.
Elements
• Clear Labels: Name each component based on its file/module name.
Final Assembly
• The DRM Handling branch, which covers license and certificate fetching, key system detection, and MediaKey setup.
• The Plugin API branch which serves as the interface layer to expose methods such as initializeMediaKeys(), detectSupportedCDMs(), and initLegacyFairplay().
This approach follows the project’s modular design as evidenced by the file tree and the comprehensive configuration and usage details in the README, ensuring a clear, maintainable, and extensible architectural overview.