How srgssr/pillarbox-web works
Main Components
• Player Component – The heart of the system is the player (src/components/player.js). It extends Video.js to provide custom functionality.
• Data Provider Module – Found in src/dataProvider, this module handles media compositions and data fetching (note the model definitions and services like DataProvider.js).
• Middleware – The middleware (src/middleware) likely intercepts or pre-processes playback and analytics data (e.g., srgssr.js).
• Trackers and Analytics – In src/trackers, components such as PillarboxMonitoring.js and SRGAnalytics.js capture playback metrics and tracking events.
• Utility/Helper Functions – Various utility modules in src/utils (like AkamaiTokenService.js, Drm.js, Image.js, PlayerEvents.js) assist with token management, digital rights handling, image processing, and event management.
• Localization – The language files (src/lang) support internationalization for different locales (e.g., en, de, fr, etc.).
• Styling and Theming – SCSS files and theme-related resources manage the look and feel of the player (located in the scss folder).
• Build Artifacts and Configuration – The build outputs (build.es.js, build.umd.js) and configuration files (Vite, Babel, ESLint, etc.) reflect how the project is bundled and maintained but are not necessarily runtime components.
Relationships and Interactions
• The Player Component interacts with the Video.js framework (external dependency) while integrating the custom features from this project.
• It calls the Data Provider service to retrieve media metadata and compositions, which feed playback decisions.
• The Middleware layer can manipulate or validate data between the player and the data provider, ensuring that SRGSSR-specific logic is enforced.
• Tracker components hook into player events (through PlayerEvents utility) to log analytics and monitoring data.
• Utility modules are used by various components (player, data provider, trackers) to perform specialized tasks such as DRM handling or token generation.
• Localization files are utilized by the player and UI components to display content in the appropriate language.
• The SCSS styling is applied directly to the player’s UI elements, affecting layout and appearance.
Architectural Patterns and Design Principles
• Modularization – Each domain (player, data provider, trackers, middleware, utils) is segregated into its own set of files and folders.
• Separation of Concerns – Presentation (player and UI components), business logic (data provider and middleware) and utility functions are clearly separated.
• Extensibility – The architecture is designed so that additional features (like new trackers or language support) can be integrated without major restructuring.
Relevant Technologies, Frameworks, and Libraries
• Video.js – The core video playback framework which is extended by Pillarbox.
• JavaScript/TypeScript – The project is primarily written in JavaScript with type definitions provided for TypeScript integration.
• Vite – Multiple Vite configuration files are present, pointing to modern bundling and development tooling.
• ESLint/Stylelint & Babel – Tools used for code quality and transformation.
• Testing Framework – Jest is configured for unit and integration tests.
• SCSS – Provides the theming and styling for the player UI.