@@ -111,6 +111,65 @@ In the sample implementation, the plugin is registered in the `createNativeModul
111
111
112
112
Once registered, your module can track player updates and report analytics data.
113
113
114
+ ### Extending Core Functionality via Plugins
115
+
116
+ In addition to analytics, plugins can also be used to modify or override core behavior of ` react-native-video ` .
117
+
118
+ This allows native modules to deeply integrate with the playback system - for example:
119
+ - replacing the media source factory,
120
+ - modifying the media item before playback starts (e.g., injecting stream keys),
121
+ - disabling caching dynamically per source.
122
+
123
+ These capabilities are available through the advanced Android plugin interface: ` RNVExoplayerPlugin ` .
124
+
125
+ > ⚠️ These extension points are optional — if no plugin provides them, the player behaves exactly as it did before.
126
+
127
+ ---
128
+
129
+ #### Plugin Extension Points (Android)
130
+
131
+ If your plugin implements ` RNVExoplayerPlugin ` , you can override the following methods:
132
+
133
+ ##### 1. ` overrideMediaItemBuilder `
134
+
135
+ Allows you to modify the ` MediaItem.Builder ` before it’s used. You can inject stream keys, cache keys, or override URIs.
136
+
137
+ ``` kotlin
138
+ override fun overrideMediaItemBuilder (
139
+ source : Source ,
140
+ mediaItemBuilder : MediaItem .Builder
141
+ ): MediaItem .Builder ? {
142
+ // Return modified builder or null to use default
143
+ }
144
+ ```
145
+
146
+ ##### 2. ` overrideMediaDataSourceFactory `
147
+
148
+ Lets you replace the data source used by ExoPlayer. Useful for implementing read-only cache or request interception.
149
+
150
+ ``` kotlin
151
+ override fun overrideMediaDataSourceFactory (
152
+ source : Source ,
153
+ mediaDataSourceFactory : DataSource .Factory
154
+ ): DataSource .Factory ? {
155
+ // Return your custom factory or null to use default
156
+ }
157
+ ```
158
+
159
+ ##### 3. ` shouldDisableCache `
160
+
161
+ Enables dynamic disabling of the caching system per source.
162
+
163
+ ``` kotlin
164
+ override fun shouldDisableCache (source : Source ): Boolean {
165
+ return true // your own logic
166
+ }
167
+ ```
168
+
169
+ ---
170
+
171
+ Once implemented, ` react-native-video ` will automatically invoke these methods for each ` <Video /> ` instance.
172
+
114
173
## iOS Implementation
115
174
116
175
### 1. Podspec Integration
@@ -308,4 +367,4 @@ class CustomVideoPlugin: RNVAVPlayerPlugin {
308
367
- On Android, the default ExoPlayer DRM implementation will be used
309
368
4 . The DRM manager must handle all DRM-related functionality:
310
369
- On iOS: key requests, license acquisition, and error handling through AVContentKeySession
311
- - On Android: DRM session management and license acquisition through ExoPlayer's DrmSessionManager
370
+ - On Android: DRM session management and license acquisition through ExoPlayer's DrmSessionManager
0 commit comments