How null2028/react-native-video works
Main components
• JavaScript/TypeScript layer: This is the core interfacing layer (found in the src folder) that exposes the Video component to React Native apps. It also includes expo-plugins (in src/expo-plugins) that help integrate with Expo projects.
• Native Android Module: Located in the android folder, this component includes the native code (many Java/Kotlin classes under com/brentvatne/ and androidx/media3/exoplayer) that implements video playback using ExoPlayer.
• Native iOS Module: Found under the ios directory, it contains Objective-C/Swift code (including bridging headers, native modules such as RCTVideoManager) to provide video functionality on Apple devices.
• Windows Module: Present in the windows folder, this module comprises Windows-specific integration based on Visual Studio projects and C++ modules that mirror the native functionality.
• Documentation & Examples: The docs and examples directories indicate that there is extensive guidance and sample usage for developers. Although these aren’t part of the runtime architecture, they play a crucial role in usage and integration.
• Build and CI/CD: Notice the .github workflows and various script folders. While not directly part of runtime, they ensure proper testing, linting, and consistent builds for multiple platforms.
Relationships and interactions
• The JavaScript/TypeScript layer dispatches calls to the native modules through React Native’s bridge. It has clearly defined interfaces (such as in src/specs) that the native parts must implement.
• Android, iOS, and Windows native components act as service providers—they receive method calls via the React Native bridge (or via Expo plugin wrappers) and interact with the underlying OS video playback APIs (e.g., ExoPlayer on Android, AVPlayer on iOS).
• The expo-plugins and additional configuration scripts adjust native configuration (for example, modifying Podfiles or Gradle files) during project builds to integrate the library seamlessly.
• The documentation examples showcase usage patterns that mimic real-world integration scenarios (e.g., BasicExample.tsx, DRMExample.tsx).
Important design patterns and technologies
• Bridge Pattern: Central to React Native, where the JavaScript side communicates with platform-specific native code.
• Platform Abstraction: The clear separation across Android, iOS, and Windows directories underscores the usage of platform-specific implementations.
• Modular Design: The project is designed to be extensible—the src folder, expo-plugins, and examples all point to a modular approach that isolates platform-specific logic from the common interface.
• Build/CI Integration: Automated workflows (via GitHub Actions), linting (ESLint, Prettier, Husky), and format checking scripts reflect a disciplined DevOps pipeline supporting quality control across multiple environments.
• Use clear labels for each component:
– “React Native Video Component (JS/TS Layer)” for the src folder.
– “Android Native Module (ExoPlayer Integration)” for the android folder.
– “iOS Native Module (AVPlayer & React Native Bridge)” for the ios folder.
– “Windows Native Module (Visual Studio Integration)” for the windows folder.
– “Expo Plugins” for integration customizations housed in src/expo-plugins.
– “CI/CD & Testing Pipeline” for GitHub workflows, scripts, and linting/formatting tools.
– “Documentation & Examples” with an indication of its supportive role.
• Be very detailed:
– Include specifics like “Expo Plugin – withRNVideo.ts” showing how plugin modifications affect the Podfile (iOS) or Gradle (Android).
– Indicate key configuration files (e.g., package.json, Podspecs, build.gradle) nearby to remind of their role in module builds.
– If desired, include a “Bridge” component between JS and native for clarity.