vdocipher-rn-bridge 1.13.2 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/VdoPlayerUIView.tsx +25 -1
- package/VdoPlayerView.tsx +8 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +131 -3
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +36 -1
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +17 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +8 -5
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModule.java +56 -16
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModule.java +54 -0
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +10 -2
- package/package.json +1 -1
- package/type.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
### 1.14.0
|
|
3
|
+
* Added `getPlaybackPropertiesV2` method to get totalPlayed and totalCovered properties
|
|
4
|
+
* Added track selection APIs for Player UI
|
|
5
|
+
|
|
2
6
|
### 1.13.2
|
|
3
7
|
* Updated VdoCipher android sdk dependency to 1.19.4
|
|
4
8
|
* Updated playerConfig to customPlayer Id
|
package/VdoPlayerUIView.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
5
|
import {requireNativeComponent, Platform} from 'react-native';
|
|
6
6
|
import { InferProps } from 'prop-types';
|
|
7
|
-
import { VdoPropTypes } from './type';
|
|
7
|
+
import { CaptionLanguage, VdoPropTypes, VideoQuality } from './type';
|
|
8
8
|
|
|
9
9
|
const VdoViewPropTypes = VdoPropTypes;
|
|
10
10
|
type MyProps = InferProps<typeof VdoViewPropTypes>;
|
|
@@ -111,6 +111,30 @@
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
setVideoQuality = (videoQuality: VideoQuality) => {
|
|
115
|
+
if (this._root) {
|
|
116
|
+
this._root.setNativeProps({videoQuality: videoQuality});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
enableAdaptiveVideo = () => {
|
|
121
|
+
if (this._root) {
|
|
122
|
+
this._root.setNativeProps({adaptiveVideo: this._propRef++});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setCaptionLanguage = (captionLanguage: CaptionLanguage) => {
|
|
127
|
+
if (this._root) {
|
|
128
|
+
this._root.setNativeProps({captionLanguage: captionLanguage});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
disableCaptions = () => {
|
|
133
|
+
if (this._root) {
|
|
134
|
+
this._root.setNativeProps({disableCaptions: this._propRef++});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
114
138
|
render() {
|
|
115
139
|
return (
|
|
116
140
|
<RCTVdoPlayerUIView ref={(component: any) => this._root = component}
|
package/VdoPlayerView.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { BackHandler, NativeModules, StyleSheet, Dimensions} from 'react-native'
|
|
|
7
7
|
import VdoPlayerSupportView from './VdoPlayerSupportView';
|
|
8
8
|
import VdoPlayerUIView from './VdoPlayerUIView';
|
|
9
9
|
import * as VdoType from './type';
|
|
10
|
-
const { TrackSelection } = NativeModules;
|
|
10
|
+
const { TrackSelection, VdoPlayer } = NativeModules;
|
|
11
11
|
|
|
12
12
|
const VdoViewPropTypes = VdoType.VdoPropTypes;
|
|
13
13
|
|
|
@@ -155,6 +155,13 @@ class VdoPlayerView extends Component<MyProps, MyState> {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
getPlaybackPropertiesV2 = async() => {
|
|
159
|
+
return new Promise(async(resolve) => { await VdoPlayer.getPlaybackPropertiesV2((playbackProperties: VdoType.PlaybackProperty) => {
|
|
160
|
+
resolve(playbackProperties);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
158
165
|
_onInitSuccess = (event: any) => {
|
|
159
166
|
if (this.props.onInitializationSuccess) {
|
|
160
167
|
this.props.onInitializationSuccess(event.nativeEvent);
|
package/android/build.gradle
CHANGED
|
@@ -18,8 +18,8 @@ apply plugin: 'com.android.library'
|
|
|
18
18
|
// TODO read from package.json
|
|
19
19
|
// "releaseVersionName" must be the same as "version" in package.json
|
|
20
20
|
// "releaseVersionCode" must increment by 1 with every release
|
|
21
|
-
def releaseVersionName = "1.
|
|
22
|
-
def releaseVersionCode =
|
|
21
|
+
def releaseVersionName = "1.14.0"
|
|
22
|
+
def releaseVersionCode = 18
|
|
23
23
|
|
|
24
24
|
android {
|
|
25
25
|
compileSdkVersion 33
|
|
@@ -23,12 +23,18 @@ import com.vdocipher.aegis.ui.view.VdoPlayerControlView;
|
|
|
23
23
|
import com.vdocipher.aegis.ui.view.VdoPlayerUIFragment;
|
|
24
24
|
import android.os.Handler;
|
|
25
25
|
import android.os.Bundle;
|
|
26
|
-
|
|
26
|
+
import android.os.Looper;
|
|
27
27
|
import androidx.core.util.Consumer;
|
|
28
28
|
import android.graphics.Color;
|
|
29
29
|
import static com.vdocipher.rnbridge.Utils.*;
|
|
30
30
|
import com.vdocipher.aegis.player.PlayerHost;
|
|
31
31
|
import androidx.core.app.PictureInPictureModeChangedInfo;
|
|
32
|
+
import com.facebook.react.bridge.Callback;
|
|
33
|
+
import com.facebook.react.bridge.WritableMap;
|
|
34
|
+
import com.facebook.react.bridge.Arguments;
|
|
35
|
+
|
|
36
|
+
import com.facebook.react.bridge.WritableArray;
|
|
37
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
32
38
|
|
|
33
39
|
|
|
34
40
|
public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventListener, Consumer<Configuration> {
|
|
@@ -52,6 +58,10 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
52
58
|
|
|
53
59
|
private Consumer<PictureInPictureModeChangedInfo> pictureModeChangedInfoConsumer;
|
|
54
60
|
|
|
61
|
+
private Track[] availableTracks;
|
|
62
|
+
private Track[] selectedTracks;
|
|
63
|
+
private Handler mainHandler;
|
|
64
|
+
|
|
55
65
|
private int resizeMode = PlayerHost.RESIZE_MODE_FIT;
|
|
56
66
|
|
|
57
67
|
public ReactVdoPlayerUIView(ThemedReactContext context) {
|
|
@@ -64,6 +74,8 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
64
74
|
context.addLifecycleEventListener(this);
|
|
65
75
|
activity.addOnConfigurationChangedListener(this);
|
|
66
76
|
|
|
77
|
+
mainHandler = new Handler(Looper.getMainLooper());
|
|
78
|
+
|
|
67
79
|
eventEmitter = new VdoEventEmitter(context);
|
|
68
80
|
|
|
69
81
|
int orientation = getResources().getConfiguration().orientation;
|
|
@@ -118,6 +130,23 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
|
|
133
|
+
public void getPlaybackPropertiesV2(Callback callback) {
|
|
134
|
+
WritableMap playbackProperties = Arguments.createMap();
|
|
135
|
+
if (vdoPlayer != null) {
|
|
136
|
+
mainHandler.post(() -> {
|
|
137
|
+
Object tp = vdoPlayer.getPlaybackProperty("totalPlayed");
|
|
138
|
+
long totalPlayed = (tp instanceof Long) ? (long)tp : 0L;
|
|
139
|
+
Object tc = vdoPlayer.getPlaybackProperty("totalCovered");
|
|
140
|
+
long totalCovered = (tc instanceof Long) ? (long)tc : 0L;
|
|
141
|
+
playbackProperties.putInt("totalPlayed", (int)totalPlayed);
|
|
142
|
+
playbackProperties.putInt("totalCovered", (int)totalCovered);
|
|
143
|
+
callback.invoke(playbackProperties);
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
callback.invoke(playbackProperties);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
public void setPlayWhenReady(boolean playWhenReady) {
|
|
122
151
|
this.playWhenReady = playWhenReady;
|
|
123
152
|
if (vdoPlayer != null) {
|
|
@@ -164,6 +193,102 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
164
193
|
}
|
|
165
194
|
}
|
|
166
195
|
|
|
196
|
+
public void isAdaptive(Callback callback) {
|
|
197
|
+
|
|
198
|
+
if (vdoPlayer != null) {
|
|
199
|
+
mainHandler.post(() -> {
|
|
200
|
+
boolean isAdaptive = vdoPlayer.isAdaptive();
|
|
201
|
+
callback.invoke(isAdaptive);
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
callback.invoke(false);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public void getVideoQualities(Callback callback) {
|
|
209
|
+
WritableArray availableVideoQualities = Arguments.createArray();
|
|
210
|
+
if (this.availableTracks != null) {
|
|
211
|
+
availableVideoQualities = makeAvailableTrackMapArray(this.availableTracks, Track.TYPE_VIDEO);
|
|
212
|
+
}
|
|
213
|
+
callback.invoke(availableVideoQualities);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public void getSelectedVideoQuality(Callback callback) {
|
|
217
|
+
WritableMap selectedVideoQuality = Arguments.createMap();
|
|
218
|
+
if (this.selectedTracks != null) {
|
|
219
|
+
selectedVideoQuality = makeSelectedVideoTrackMap(this.selectedTracks);
|
|
220
|
+
}
|
|
221
|
+
callback.invoke(selectedVideoQuality);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public void getSelectedAudioQuality(Callback callback) {
|
|
225
|
+
WritableMap selectedAudioQuality = Arguments.createMap();
|
|
226
|
+
if (this.selectedTracks != null) {
|
|
227
|
+
selectedAudioQuality = makeSelectedAudioTrackMap(this.selectedTracks);
|
|
228
|
+
}
|
|
229
|
+
callback.invoke(selectedAudioQuality);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public void getCaptionLanguages(Callback callback) {
|
|
233
|
+
WritableArray availableCaptionLanguages = Arguments.createArray();
|
|
234
|
+
if (this.availableTracks != null) {
|
|
235
|
+
availableCaptionLanguages = makeAvailableTrackMapArray(this.availableTracks, Track.TYPE_CAPTIONS);
|
|
236
|
+
}
|
|
237
|
+
callback.invoke(availableCaptionLanguages);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public void getSelectedCaptionLanguage(Callback callback) {
|
|
241
|
+
WritableMap selectedCaptionLanguage = Arguments.createMap();
|
|
242
|
+
if (this.selectedTracks != null) {
|
|
243
|
+
selectedCaptionLanguage = makeSelectedCaptionTrackMap(this.selectedTracks);
|
|
244
|
+
}
|
|
245
|
+
callback.invoke(selectedCaptionLanguage);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public void getDuration(Callback callback) {
|
|
249
|
+
|
|
250
|
+
if (vdoPlayer != null) {
|
|
251
|
+
mainHandler.post(() -> {
|
|
252
|
+
double videoDuration = vdoPlayer.getDuration();
|
|
253
|
+
WritableMap videoDurationMap = Arguments.createMap();
|
|
254
|
+
videoDurationMap.putDouble("duration", videoDuration);
|
|
255
|
+
callback.invoke(videoDurationMap);
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
callback.invoke(0);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
public void setSelectedTrack(ReadableMap selectedTrackMap) {
|
|
263
|
+
Track selectedTrack = makeTrack(selectedTrackMap, availableTracks);
|
|
264
|
+
|
|
265
|
+
if (vdoPlayer != null && selectedTrack != null) {
|
|
266
|
+
mainHandler.post(() -> {
|
|
267
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public void enableAdaptiveVideo() {
|
|
273
|
+
Track selectedTrack = Track.SET_ADAPTIVE;
|
|
274
|
+
|
|
275
|
+
if (vdoPlayer != null) {
|
|
276
|
+
mainHandler.post(() -> {
|
|
277
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
public void disableCaptions() {
|
|
283
|
+
Track selectedTrack = Track.DISABLE_CAPTIONS;
|
|
284
|
+
|
|
285
|
+
if (vdoPlayer != null) {
|
|
286
|
+
mainHandler.post(() -> {
|
|
287
|
+
vdoPlayer.setSelectedTracks(new Track[]{selectedTrack});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
167
292
|
@Override
|
|
168
293
|
public void setId(int id) {
|
|
169
294
|
super.setId(id);
|
|
@@ -246,6 +371,8 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
246
371
|
public void onInitializationSuccess(PlayerHost playerHost, VdoPlayer player, boolean restored) {
|
|
247
372
|
Log.d(TAG, "init success");
|
|
248
373
|
vdoPlayer = player;
|
|
374
|
+
availableTracks = vdoPlayer.getAvailableTracks();
|
|
375
|
+
selectedTracks = vdoPlayer.getSelectedTracks();
|
|
249
376
|
vdoPlayer.addPlaybackEventListener(playbackListener);
|
|
250
377
|
eventEmitter.initSuccess(restored);
|
|
251
378
|
|
|
@@ -280,8 +407,9 @@ public class ReactVdoPlayerUIView extends FrameLayout implements LifecycleEventL
|
|
|
280
407
|
}
|
|
281
408
|
|
|
282
409
|
@Override
|
|
283
|
-
public void onTracksChanged(Track[]
|
|
284
|
-
|
|
410
|
+
public void onTracksChanged(Track[] tracksAvailable, Track[] tracksSelected) {
|
|
411
|
+
availableTracks = tracksAvailable;
|
|
412
|
+
selectedTracks = tracksSelected;
|
|
285
413
|
eventEmitter.tracksChanged(availableTracks, selectedTracks);
|
|
286
414
|
}
|
|
287
415
|
|
|
@@ -13,6 +13,7 @@ import com.vdocipher.aegis.player.VdoInitParams;
|
|
|
13
13
|
import java.util.Map;
|
|
14
14
|
|
|
15
15
|
import javax.annotation.Nullable;
|
|
16
|
+
import java.util.concurrent.CopyOnWriteArraySet;
|
|
16
17
|
|
|
17
18
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
18
19
|
|
|
@@ -21,6 +22,9 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
21
22
|
|
|
22
23
|
private static final String REACT_CLASS = "RCTVdoPlayerUIView";
|
|
23
24
|
|
|
25
|
+
private ReactVdoPlayerUIView playerView;
|
|
26
|
+
private CopyOnWriteArraySet<Listener> listeners = new CopyOnWriteArraySet<>();
|
|
27
|
+
|
|
24
28
|
@Override
|
|
25
29
|
public String getName() {
|
|
26
30
|
return REACT_CLASS;
|
|
@@ -28,11 +32,18 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
28
32
|
|
|
29
33
|
@Override
|
|
30
34
|
public ReactVdoPlayerUIView createViewInstance(ThemedReactContext context) {
|
|
31
|
-
|
|
35
|
+
playerView = new ReactVdoPlayerUIView(context);
|
|
32
36
|
Log.d(TAG, "created " + playerView.toString());
|
|
37
|
+
for (Listener listener : listeners) {
|
|
38
|
+
listener.onVideoPlayerViewInitialised(playerView);
|
|
39
|
+
}
|
|
33
40
|
return playerView;
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
public void addListener(Listener listener) {
|
|
44
|
+
listeners.add(listener);
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
@Nullable
|
|
37
48
|
@Override
|
|
38
49
|
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
|
@@ -162,4 +173,28 @@ public class ReactVdoPlayerUIViewManager extends ViewGroupManager<ReactVdoPlayer
|
|
|
162
173
|
public void setAspectRatio(ReactVdoPlayerUIView vdoPlayerView, float aspectRatio) {
|
|
163
174
|
vdoPlayerView.setAspectRatio(aspectRatio);
|
|
164
175
|
}
|
|
176
|
+
|
|
177
|
+
@ReactProp(name = "videoQuality")
|
|
178
|
+
public void setVideoQuality(ReactVdoPlayerUIView vdoPlayerView, ReadableMap videoQuality) {
|
|
179
|
+
vdoPlayerView.setSelectedTrack(videoQuality);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@ReactProp(name = "adaptiveVideo")
|
|
183
|
+
public void enableAdaptiveVideo(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
184
|
+
vdoPlayerView.enableAdaptiveVideo();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@ReactProp(name = "captionLanguage")
|
|
188
|
+
public void setCaptionLanguage(ReactVdoPlayerUIView vdoPlayerView, ReadableMap captionLanguage) {
|
|
189
|
+
vdoPlayerView.setSelectedTrack(captionLanguage);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@ReactProp(name = "disableCaptions")
|
|
193
|
+
public void disableCaptions(ReactVdoPlayerUIView vdoPlayerView, int ref) {
|
|
194
|
+
vdoPlayerView.disableCaptions();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public interface Listener {
|
|
198
|
+
void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerView);
|
|
199
|
+
}
|
|
165
200
|
}
|
|
@@ -176,6 +176,23 @@ public class ReactVdoPlayerView extends FrameLayout implements LifecycleEventLis
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
public void getPlaybackPropertiesV2(Callback callback) {
|
|
180
|
+
WritableMap playbackProperties = Arguments.createMap();
|
|
181
|
+
if (vdoPlayer != null) {
|
|
182
|
+
mainHandler.post(() -> {
|
|
183
|
+
Object tp = vdoPlayer.getPlaybackProperty("totalPlayed");
|
|
184
|
+
long totalPlayed = (tp instanceof Long) ? (long)tp : 0L;
|
|
185
|
+
Object tc = vdoPlayer.getPlaybackProperty("totalCovered");
|
|
186
|
+
long totalCovered = (tc instanceof Long) ? (long)tc : 0L;
|
|
187
|
+
playbackProperties.putInt("totalPlayed", (int)totalPlayed);
|
|
188
|
+
playbackProperties.putInt("totalCovered", (int)totalCovered);
|
|
189
|
+
callback.invoke(playbackProperties);
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
callback.invoke(playbackProperties);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
179
196
|
public void setPlayWhenReady(boolean playWhenReady) {
|
|
180
197
|
this.playWhenReady = playWhenReady;
|
|
181
198
|
if (vdoPlayer != null) {
|
|
@@ -13,6 +13,7 @@ import com.vdocipher.aegis.media.Track;
|
|
|
13
13
|
import java.util.Map;
|
|
14
14
|
|
|
15
15
|
import javax.annotation.Nullable;
|
|
16
|
+
import java.util.concurrent.CopyOnWriteArraySet;
|
|
16
17
|
|
|
17
18
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
18
19
|
import com.facebook.react.bridge.ReadableMap;
|
|
@@ -23,7 +24,7 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
23
24
|
private static final String REACT_CLASS = "RCTVdoPlayerView";
|
|
24
25
|
|
|
25
26
|
private ReactVdoPlayerView playerView;
|
|
26
|
-
private
|
|
27
|
+
private CopyOnWriteArraySet<Listener> listeners = new CopyOnWriteArraySet<>();
|
|
27
28
|
|
|
28
29
|
@Override
|
|
29
30
|
public String getName() {
|
|
@@ -34,12 +35,14 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
34
35
|
public ReactVdoPlayerView createViewInstance(ThemedReactContext context) {
|
|
35
36
|
playerView = new ReactVdoPlayerView(context);
|
|
36
37
|
Log.d(TAG, "created " + playerView.toString());
|
|
37
|
-
|
|
38
|
+
for (Listener listener : listeners) {
|
|
39
|
+
listener.onVideoPlayerViewInitialised(playerView);
|
|
40
|
+
}
|
|
38
41
|
return playerView;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
public void
|
|
42
|
-
|
|
44
|
+
public void addListener(Listener listener) {
|
|
45
|
+
listeners.add(listener);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
@Nullable
|
|
@@ -168,7 +171,7 @@ public class ReactVdoPlayerViewManager extends ViewGroupManager<ReactVdoPlayerVi
|
|
|
168
171
|
vdoPlayerView.disableCaptions();
|
|
169
172
|
}
|
|
170
173
|
|
|
171
|
-
public interface
|
|
174
|
+
public interface Listener {
|
|
172
175
|
void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView);
|
|
173
176
|
}
|
|
174
177
|
|
|
@@ -8,74 +8,109 @@ import com.facebook.react.bridge.Callback;
|
|
|
8
8
|
import android.util.Log;
|
|
9
9
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
10
|
|
|
11
|
-
public class TrackSelectionModule extends ReactContextBaseJavaModule implements ReactVdoPlayerViewManager.
|
|
11
|
+
public class TrackSelectionModule extends ReactContextBaseJavaModule implements ReactVdoPlayerViewManager.Listener, ReactVdoPlayerUIViewManager.Listener {
|
|
12
12
|
private static final String TAG = "TrackSelectionModule";
|
|
13
13
|
|
|
14
14
|
private ReactVdoPlayerView vdoPlayerView;
|
|
15
|
+
private ReactVdoPlayerUIView vdoPlayerUIView;
|
|
15
16
|
|
|
16
17
|
@Override
|
|
17
18
|
public String getName() {
|
|
18
19
|
return "TrackSelection";
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
public TrackSelectionModule(ReactApplicationContext reactContext, ReactVdoPlayerViewManager vdoPlayerViewManager) {
|
|
22
|
+
public TrackSelectionModule(ReactApplicationContext reactContext, ReactVdoPlayerViewManager vdoPlayerViewManager, ReactVdoPlayerUIViewManager vdoPlayerUIViewManager) {
|
|
22
23
|
super(reactContext);
|
|
23
24
|
if (vdoPlayerViewManager != null) {
|
|
24
|
-
vdoPlayerViewManager.
|
|
25
|
+
vdoPlayerViewManager.addListener(this);
|
|
26
|
+
}
|
|
27
|
+
if (vdoPlayerUIViewManager != null) {
|
|
28
|
+
vdoPlayerUIViewManager.addListener(this);
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
@ReactMethod
|
|
29
33
|
public void isAdaptive(com.facebook.react.bridge.Callback callback) {
|
|
30
|
-
if (vdoPlayerView == null) {
|
|
34
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
|
-
vdoPlayerView
|
|
37
|
+
if (vdoPlayerView != null) {
|
|
38
|
+
vdoPlayerView.isAdaptive(callback);
|
|
39
|
+
} else {
|
|
40
|
+
vdoPlayerUIView.isAdaptive(callback);
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
@ReactMethod
|
|
37
45
|
public void getVideoQualities(com.facebook.react.bridge.Callback callback) {
|
|
38
|
-
if (vdoPlayerView == null) {
|
|
46
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
39
47
|
return;
|
|
40
48
|
}
|
|
41
|
-
vdoPlayerView
|
|
49
|
+
if (vdoPlayerView != null) {
|
|
50
|
+
vdoPlayerView.getVideoQualities(callback);
|
|
51
|
+
} else {
|
|
52
|
+
vdoPlayerUIView.getVideoQualities(callback);
|
|
53
|
+
}
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
@ReactMethod
|
|
45
57
|
public void getSelectedVideoQuality(com.facebook.react.bridge.Callback callback) {
|
|
46
|
-
if (vdoPlayerView == null) {
|
|
58
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
47
59
|
return;
|
|
48
60
|
}
|
|
49
|
-
vdoPlayerView
|
|
61
|
+
if (vdoPlayerView != null) {
|
|
62
|
+
vdoPlayerView.getSelectedVideoQuality(callback);
|
|
63
|
+
} else {
|
|
64
|
+
vdoPlayerUIView.getSelectedVideoQuality(callback);
|
|
65
|
+
}
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
@ReactMethod
|
|
53
69
|
public void getSelectedAudioQuality(com.facebook.react.bridge.Callback callback) {
|
|
54
|
-
if (vdoPlayerView == null) {
|
|
70
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
55
71
|
return;
|
|
56
72
|
}
|
|
57
|
-
vdoPlayerView
|
|
73
|
+
if (vdoPlayerView != null) {
|
|
74
|
+
vdoPlayerView.getSelectedAudioQuality(callback);
|
|
75
|
+
} else {
|
|
76
|
+
vdoPlayerUIView.getSelectedAudioQuality(callback);
|
|
77
|
+
}
|
|
58
78
|
}
|
|
59
79
|
|
|
60
80
|
@ReactMethod
|
|
61
81
|
public void getCaptionLanguages(com.facebook.react.bridge.Callback callback) {
|
|
62
|
-
if (vdoPlayerView == null) {
|
|
82
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
63
83
|
return;
|
|
64
84
|
}
|
|
65
|
-
vdoPlayerView
|
|
85
|
+
if (vdoPlayerView != null) {
|
|
86
|
+
vdoPlayerView.getCaptionLanguages(callback);
|
|
87
|
+
} else {
|
|
88
|
+
vdoPlayerUIView.getCaptionLanguages(callback);
|
|
89
|
+
}
|
|
66
90
|
}
|
|
67
91
|
|
|
68
92
|
@ReactMethod
|
|
69
93
|
public void getSelectedCaptionLanguage(com.facebook.react.bridge.Callback callback) {
|
|
70
|
-
if (vdoPlayerView == null) {
|
|
94
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
71
95
|
return;
|
|
72
96
|
}
|
|
73
|
-
vdoPlayerView
|
|
97
|
+
if (vdoPlayerView != null) {
|
|
98
|
+
vdoPlayerView.getSelectedCaptionLanguage(callback);
|
|
99
|
+
} else {
|
|
100
|
+
vdoPlayerUIView.getSelectedCaptionLanguage(callback);
|
|
101
|
+
}
|
|
74
102
|
}
|
|
75
103
|
|
|
76
104
|
@ReactMethod()
|
|
77
105
|
public void getDuration(com.facebook.react.bridge.Callback callback) {
|
|
78
|
-
vdoPlayerView
|
|
106
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (vdoPlayerView != null) {
|
|
110
|
+
vdoPlayerView.getDuration(callback);
|
|
111
|
+
} else {
|
|
112
|
+
vdoPlayerUIView.getDuration(callback);
|
|
113
|
+
}
|
|
79
114
|
}
|
|
80
115
|
|
|
81
116
|
@Override
|
|
@@ -83,4 +118,9 @@ public class TrackSelectionModule extends ReactContextBaseJavaModule implements
|
|
|
83
118
|
this.vdoPlayerView = vdoPlayerView;
|
|
84
119
|
}
|
|
85
120
|
|
|
121
|
+
@Override
|
|
122
|
+
public void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerUIView) {
|
|
123
|
+
this.vdoPlayerUIView = vdoPlayerUIView;
|
|
124
|
+
}
|
|
125
|
+
|
|
86
126
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.bridge.Callback;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
10
|
+
|
|
11
|
+
public class VdoPlayerModule extends ReactContextBaseJavaModule implements ReactVdoPlayerViewManager.Listener, ReactVdoPlayerUIViewManager.Listener {
|
|
12
|
+
private static final String TAG = "VdoPlayerModule";
|
|
13
|
+
|
|
14
|
+
private ReactVdoPlayerView vdoPlayerView;
|
|
15
|
+
private ReactVdoPlayerUIView vdoPlayerUIView;
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public String getName() {
|
|
19
|
+
return "VdoPlayer";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public VdoPlayerModule(ReactApplicationContext reactContext, ReactVdoPlayerViewManager vdoPlayerViewManager, ReactVdoPlayerUIViewManager vdoPlayerUIViewManager) {
|
|
23
|
+
super(reactContext);
|
|
24
|
+
if (vdoPlayerViewManager != null) {
|
|
25
|
+
vdoPlayerViewManager.addListener(this);
|
|
26
|
+
}
|
|
27
|
+
if (vdoPlayerUIViewManager != null) {
|
|
28
|
+
vdoPlayerUIViewManager.addListener(this);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod()
|
|
33
|
+
public void getPlaybackPropertiesV2(com.facebook.react.bridge.Callback callback) {
|
|
34
|
+
if (vdoPlayerView == null && vdoPlayerUIView == null) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (vdoPlayerView != null) {
|
|
38
|
+
vdoPlayerView.getPlaybackPropertiesV2(callback);
|
|
39
|
+
} else {
|
|
40
|
+
vdoPlayerUIView.getPlaybackPropertiesV2(callback);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView) {
|
|
46
|
+
this.vdoPlayerView = vdoPlayerView;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public void onVideoPlayerViewInitialised(ReactVdoPlayerUIView vdoPlayerUIView) {
|
|
51
|
+
this.vdoPlayerUIView = vdoPlayerUIView;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -12,16 +12,21 @@ import com.facebook.react.bridge.JavaScriptModule;
|
|
|
12
12
|
|
|
13
13
|
public class VdocipherRnBridgePackage implements ReactPackage {
|
|
14
14
|
private ReactVdoPlayerViewManager vdoPlayerViewManager;
|
|
15
|
+
private ReactVdoPlayerUIViewManager vdoPlayerUIViewManager;
|
|
15
16
|
|
|
16
17
|
@Override
|
|
17
18
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
18
19
|
if (vdoPlayerViewManager == null) {
|
|
19
20
|
vdoPlayerViewManager = new ReactVdoPlayerViewManager();
|
|
20
21
|
}
|
|
22
|
+
if (vdoPlayerUIViewManager == null) {
|
|
23
|
+
vdoPlayerUIViewManager = new ReactVdoPlayerUIViewManager();
|
|
24
|
+
}
|
|
21
25
|
return Arrays.<NativeModule>asList(
|
|
22
26
|
new VdocipherRnBridgeModule(reactContext),
|
|
23
27
|
new VdoDownloadModule(reactContext),
|
|
24
|
-
new TrackSelectionModule(reactContext, vdoPlayerViewManager)
|
|
28
|
+
new TrackSelectionModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager),
|
|
29
|
+
new VdoPlayerModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager));
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
// Deprecated from RN 0.47
|
|
@@ -34,8 +39,11 @@ public class VdocipherRnBridgePackage implements ReactPackage {
|
|
|
34
39
|
if (vdoPlayerViewManager == null) {
|
|
35
40
|
vdoPlayerViewManager = new ReactVdoPlayerViewManager();
|
|
36
41
|
}
|
|
42
|
+
if (vdoPlayerUIViewManager == null) {
|
|
43
|
+
vdoPlayerUIViewManager = new ReactVdoPlayerUIViewManager();
|
|
44
|
+
}
|
|
37
45
|
return Arrays.<ViewManager>asList(
|
|
38
|
-
|
|
46
|
+
vdoPlayerUIViewManager,
|
|
39
47
|
vdoPlayerViewManager
|
|
40
48
|
);
|
|
41
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vdocipher-rn-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "React native bridge library that delegates to vdocipher native android SDK",
|
|
5
5
|
"homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
|
|
6
6
|
"scripts": {
|
package/type.ts
CHANGED
|
@@ -101,6 +101,11 @@ export interface CaptionLanguage {
|
|
|
101
101
|
label: string;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export interface PlaybackProperty {
|
|
105
|
+
totalPlayed: number;
|
|
106
|
+
totalCovered: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
export const VdoPropTypes = {
|
|
105
110
|
/* Native only */
|
|
106
111
|
onInitSuccess: PropTypes.func,
|