mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-11 01:48:53 -05:00
Added an explicit width of 2.5em to the NextVideoButton to ensure consistent sizing in the video player controls.
Video.js Components
This directory contains the organized Video.js components, separated into logical modules for better maintainability and reusability.
Directory Structure
components/
├── controls/ # Control components (buttons, menus, etc.)
│ └── NextVideoButton.js
├── markers/ # Progress bar markers and indicators
│ └── ChapterMarkers.js
├── overlays/ # Overlay components (end screens, popups, etc.)
│ └── EndScreenOverlay.js
├── video-player/ # Main video player component
│ └── VideoJSPlayer.jsx
├── index.js # Main exports file
└── README.md # This file
Components Overview
VideoJSPlayer (Main Component)
- Location:
video-player/VideoJSPlayer.jsx - Purpose: Main Video.js player component that orchestrates all other components
- Features:
- Video.js initialization and configuration
- Event handling and lifecycle management
- Integration with all sub-components
EndScreenOverlay
- Location:
overlays/EndScreenOverlay.js - Purpose: Displays related videos when the current video ends
- Features:
- Grid layout for related videos
- Thumbnail and metadata display
- Click navigation to related videos
ChapterMarkers
- Location:
markers/ChapterMarkers.js - Purpose: Provides chapter navigation on the progress bar
- Features:
- Visual chapter markers on progress bar
- Floating tooltip with chapter information
- Click-to-jump functionality
- Continuous chapter display while hovering
NextVideoButton
- Location:
controls/NextVideoButton.js - Purpose: Custom control bar button for next video navigation
- Features:
- Custom SVG icon
- Accessibility support
- Event triggering for next video functionality
Usage
Import Individual Components
import EndScreenOverlay from './components/overlays/EndScreenOverlay';
import ChapterMarkers from './components/markers/ChapterMarkers';
import NextVideoButton from './components/controls/NextVideoButton';
Import from Index
import {
VideoJSPlayer,
EndScreenOverlay,
ChapterMarkers,
NextVideoButton,
} from './components';
Use Main Component
import { VideoJSPlayer } from './components';
function App() {
return <VideoJSPlayer />;
}
Development Guidelines
- Separation of Concerns: Each component should have a single, well-defined responsibility
- Video.js Registration: Each component registers itself with Video.js using
videojs.registerComponent() - Event Handling: Use Video.js event system for communication between components
- Cleanup: Implement proper cleanup in
dispose()methods to prevent memory leaks - Accessibility: Ensure all components follow accessibility best practices
Adding New Components
- Create the component in the appropriate subdirectory
- Register it with Video.js using
videojs.registerComponent() - Export it from the subdirectory's index file (if needed)
- Add it to the main
components/index.jsfile - Update this README with the new component information
Dependencies
- video.js: Core Video.js library
- React: For the main VideoJSPlayer component
- videojs.dom: For DOM manipulation utilities
- videojs.getComponent: For extending Video.js base components