You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both android and iOS implementation expose an interface `RNVPlugin`.
29
-
Your `react-native-video-custom-analytics` shall implement this interface and register itself as a plugin for react native video.
28
+
Both Android and iOS implementations expose two interfaces:
29
+
-`RNVPlugin`: Base interface for all RNV plugins that doesn't have dependencies nor logic specific to any player
30
+
- Player-specific interfaces: `RNVExoplayerPlugin` (Android) and `RNVAVPlayerPlugin` (iOS) for plugins that need direct access to the specific player implementations
31
+
32
+
Your `react-native-video-custom-analytics` shall implement one of these interfaces and register itself as a plugin for react native video.
30
33
31
34
## Android
32
-
There is no special requierement for gradle file.
33
-
You need two mandatory action to be able to receive player handle
35
+
36
+
There is no special requirement for gradle file.
37
+
You need two mandatory actions to be able to receive player handle.
34
38
35
39
### 1/ Create the plugin
36
40
37
-
First you should instanciate a class which extends `RNVPlugin`.
41
+
You have two options for implementing a plugin on Android:
38
42
39
-
The proposed integration implement `RNVPlugin` directly inside the Module file (`VideoPluginSampleModule`).
43
+
#### Option 1: Basic Plugin (RNVPlugin)
40
44
41
-
The `RNVPlugin` interface defines following functions, see description here under.
45
+
For plugins that don't need Exoplayer-specific functionality, implement the `RNVPlugin` interface:
42
46
43
47
```kotlin
48
+
interfaceRNVPlugin {
44
49
/**
45
50
* Function called when a new player is created
46
51
* @param id: a random string identifying the player
47
52
* @param player: the instantiated player reference
48
53
*/
49
54
funonInstanceCreated(id:String, player:Any)
55
+
50
56
/**
51
57
* Function called when a player should be destroyed
52
58
* when this callback is called, the plugin shall free all
@@ -55,79 +61,136 @@ The `RNVPlugin` interface defines following functions, see description here unde
For plugins that need direct access to Exoplayer functionality, implement the `RNVExoplayerPlugin` interface:
70
+
71
+
```kotlin
72
+
interfaceRNVExoplayerPlugin : RNVPlugin {
59
73
/**
60
74
* Optional function that allows plugin to provide custom DRM manager
61
75
* Only one plugin can provide DRM manager at a time
62
76
* @return DRMManagerSpec implementation if plugin wants to handle DRM, null otherwise
63
77
*/
64
-
fungetDRMManager(): DRMManagerSpec? {
65
-
returnnull
66
-
}
78
+
fungetDRMManager(): DRMManagerSpec?=null
79
+
80
+
/**
81
+
* Function called when a new player is created
82
+
* @param id: a random string identifying the player
83
+
* @param player: the instantiated player reference
84
+
* @note: This is helper that ensure that player is non null ExoPlayer
85
+
*/
86
+
funonInstanceCreated(id:String, player:ExoPlayer)
87
+
88
+
/**
89
+
* Function called when a player should be destroyed
90
+
* when this callback is called, the plugin shall free all
91
+
* resources and release all reference to Player object
92
+
* @param id: a random string identifying the player
93
+
* @param player: the player to release
94
+
* @note: This is helper that ensure that player is non null ExoPlayer
95
+
*/
96
+
funonInstanceRemoved(id:String, player:ExoPlayer)
97
+
}
67
98
```
68
99
69
-
### 2/ register the plugin
100
+
The `RNVExoplayerPlugin` interface already implements the base `RNVPlugin` methods by providing type-safe wrappers that ensure you receive an ExoPlayer instance.
70
101
71
-
To register this allocated class in the main react native video package you should call following function:
102
+
### 2/ Register the plugin
103
+
104
+
To register your plugin with the main react native video package, call the following function:
The `RNVAVPlayerPlugin` class already extends from the base `RNVPlugin` class and provides type-safe wrappers that ensure you receive an AVPlayer instance.
184
+
122
185
### 3/ Register the plugin
123
186
124
-
To register this allocated class in the main react native video package you should register it by calling this function:
187
+
To register your plugin with the main react native video package, call this function:
0 commit comments