How cookpete/react-player works
Main Components Structure
a) Core Layer
• Central ReactPlayer component (src/ReactPlayer.js)
• Player base component (src/Player.js)
• Preview component (src/Preview.js)
b) Player Implementations Layer
• Multiple player implementations (src/players/*)
• Each player adapter (YouTube, Facebook, Vimeo, etc.)
c) Utility Layer
• Utility functions (src/utils.js)
• Pattern matching (src/patterns.js)
• Props validation (src/props.js)
Component Relationships
a) Data Flow
• How the main ReactPlayer component delegates to specific player implementations
• How the Preview component interacts with the main player
• Configuration flow from props to player instances
b) Player Selection Flow
• URL pattern matching process
• Player instantiation logic
• Lazy loading paths (when using react-player/lazy)
Integration Points
External integrations:
a) Third-party SDKs
• YouTube iFrame API
• Facebook Embedded Video Player API
• Vimeo Player API
• Other platform-specific APIs
b) Media Handling
• Native HTML5 video/audio elements
• HLS.js integration
• DASH.js integration
Implementation Details
Technical aspects:
a) Configuration
• How config prop flows through components
• Player-specific configuration paths
b) Event System
• Callback prop flow
• Event handling paths
• Error boundaries
Bottom Level: Utilities and external services
Key Annotations:
• Lazy-loaded boundaries
• Supported media types
• Configuration injection points
• Event propagation paths
Remember to:
• Notes about key architectural decisions
• Both synchronous and asynchronous paths