vdocipher-rn-bridge 1.22.7 → 2.0.1
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/VdoPlayerSupportView.tsx +12 -70
- package/VdoPlayerUIView.tsx +29 -90
- package/VdoPlayerView.tsx +36 -73
- package/android/build.gradle +23 -4
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/vdocipher/rnbridge/PlayerViewRegistry.java +34 -0
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerUIView.java +7 -11
- package/android/src/main/java/com/vdocipher/rnbridge/{ReactVdoPlayerUIViewManager.java → ReactVdoPlayerUIViewManagerImpl.java} +66 -80
- package/android/src/main/java/com/vdocipher/rnbridge/ReactVdoPlayerView.java +8 -12
- package/android/src/main/java/com/vdocipher/rnbridge/{ReactVdoPlayerViewManager.java → ReactVdoPlayerViewManagerImpl.java} +61 -75
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModuleImpl.java +64 -0
- package/android/src/main/java/com/vdocipher/rnbridge/Utils.java +27 -0
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoDownloadModule.java → VdoDownloadModuleImpl.java} +23 -50
- package/android/src/main/java/com/vdocipher/rnbridge/VdoEventEmitter.java +51 -17
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModuleImpl.java +28 -0
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoPlayerSettingsModule.java → VdoPlayerSettingsModuleImpl.java} +3 -8
- package/android/src/main/java/com/vdocipher/rnbridge/{VdoPreCacheManagerModule.java → VdoPreCacheManagerModuleImpl.java} +3 -10
- package/android/src/main/java/com/vdocipher/rnbridge/{VdocipherRnBridgeModule.java → VdocipherRnBridgeModuleImpl.java} +5 -16
- package/android/src/main/java/com/vdocipher/rnbridge/VdocipherRnBridgePackage.java +13 -27
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +195 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +174 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/TrackSelectionModule.java +61 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoDownloadModule.java +129 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +29 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +42 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdoPreCacheManagerModule.java +43 -0
- package/android/src/newarch/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +44 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerUIViewManager.java +114 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/ReactVdoPlayerViewManager.java +109 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/TrackSelectionModule.java +59 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoDownloadModule.java +132 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerModule.java +29 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPlayerSettingsModule.java +40 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdoPreCacheManagerModule.java +40 -0
- package/android/src/oldarch/java/com/vdocipher/rnbridge/VdocipherRnBridgeModule.java +40 -0
- package/downloads.ts +5 -5
- package/ios/RCTVdoPlayerUIView.h +4 -4
- package/ios/RCTVdoPlayerUIView.swift +2 -1
- package/ios/RCTVdoPlayerUIViewComponentView.mm +127 -0
- package/ios/RCTVdoPlayerView.swift +1 -0
- package/ios/RCTVdoPlayerViewComponentView.mm +127 -0
- package/ios/VdoCipherRNView.h +16 -3
- package/ios/VdoCipherRNView.swift +44 -8
- package/ios/VdoPlayerCommandDispatch.h +52 -0
- package/ios/VdoPreCacheManager.swift +1 -1
- package/ios/VdocipherRnBridgeViewManager.mm +234 -0
- package/ios/VdocipherRnBridgeViewManager.swift +4 -4
- package/package.json +46 -3
- package/react-native-vdocipher-rn-bridge.podspec +4 -15
- package/specs/NativeTrackSelection.ts +38 -0
- package/specs/NativeVdoDownload.ts +76 -0
- package/specs/NativeVdoEventEmitter.ts +12 -0
- package/specs/NativeVdoPlayer.ts +11 -0
- package/specs/NativeVdoPlayerSettings.ts +13 -0
- package/specs/NativeVdoPreCacheManager.ts +12 -0
- package/specs/NativeVdocipherRnBridge.ts +11 -0
- package/specs/RCTVdoPlayerUIViewNativeComponent.ts +93 -0
- package/specs/RCTVdoPlayerViewNativeComponent.ts +84 -0
- package/tsconfig.json +1 -1
- package/type.ts +84 -90
- package/android/src/main/java/com/vdocipher/rnbridge/TrackSelectionModule.java +0 -126
- package/android/src/main/java/com/vdocipher/rnbridge/VdoPlayerModule.java +0 -54
- package/ios/VdocipherRnBridgeViewManager.m +0 -126
|
@@ -8,7 +8,6 @@ import com.facebook.react.bridge.Callback;
|
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
9
|
import com.facebook.react.bridge.ReactContext;
|
|
10
10
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
12
11
|
import com.facebook.react.bridge.ReadableArray;
|
|
13
12
|
import com.facebook.react.bridge.ReadableMap;
|
|
14
13
|
import com.facebook.react.bridge.WritableMap;
|
|
@@ -42,37 +41,24 @@ import static com.vdocipher.rnbridge.Utils.*;
|
|
|
42
41
|
* <li>Manage downloads (query or delete downloads)
|
|
43
42
|
*/
|
|
44
43
|
|
|
45
|
-
public class
|
|
44
|
+
public class VdoDownloadModuleImpl implements VdoDownloadManager.EventListener {
|
|
46
45
|
private static final String TAG = "VdoDownloadModule";
|
|
46
|
+
public static final String NAME = "VdoDownload";
|
|
47
47
|
|
|
48
48
|
private Handler mainHandler;
|
|
49
49
|
|
|
50
|
-
private
|
|
50
|
+
private HashMap<String, DownloadOptions> downloadOptionsStore;
|
|
51
51
|
private static final String DEFAULT_DOWNLOAD_DIRECTORY_NAME = "offlineVdos";
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
private ReactApplicationContext reactApplicationContext;
|
|
54
|
+
|
|
55
|
+
public VdoDownloadModuleImpl(ReactApplicationContext reactContext) {
|
|
55
56
|
downloadOptionsStore = new HashMap<>();
|
|
56
57
|
VdoDownloadManager.getInstance(reactContext).addEventListener(this);
|
|
57
58
|
mainHandler = new Handler(Looper.getMainLooper());
|
|
59
|
+
reactApplicationContext = reactContext;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
@Override
|
|
61
|
-
public String getName() {
|
|
62
|
-
return "VdoDownload";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@ReactMethod
|
|
66
|
-
public void addListener(String eventName) {
|
|
67
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@ReactMethod
|
|
71
|
-
public void removeListeners(Integer count) {
|
|
72
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@ReactMethod
|
|
76
62
|
public void getDownloadOptions(ReadableMap optionParams,
|
|
77
63
|
Callback errorCallback,
|
|
78
64
|
Callback successCallback) {
|
|
@@ -94,7 +80,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
94
80
|
}
|
|
95
81
|
|
|
96
82
|
|
|
97
|
-
OptionsDownloader optionsDownloader = new OptionsDownloader(
|
|
83
|
+
OptionsDownloader optionsDownloader = new OptionsDownloader(reactApplicationContext);
|
|
98
84
|
|
|
99
85
|
try {
|
|
100
86
|
if (token != null && mediaId != null) {
|
|
@@ -150,15 +136,6 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
150
136
|
}
|
|
151
137
|
}
|
|
152
138
|
|
|
153
|
-
@ReactMethod
|
|
154
|
-
public void enqueueDownload(String nativeId,
|
|
155
|
-
ReadableMap requestOptions,
|
|
156
|
-
Callback errorCallback,
|
|
157
|
-
Callback successCallback) {
|
|
158
|
-
enqueueDownload(nativeId, requestOptions, new EnqueueFailureCallback(errorCallback), successCallback);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@ReactMethod
|
|
162
139
|
public void query(ReadableMap queryFilters,
|
|
163
140
|
Callback errorCallback,
|
|
164
141
|
Callback successCallback) {
|
|
@@ -186,7 +163,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
186
163
|
query.setFilterByStatus(statuses);
|
|
187
164
|
}
|
|
188
165
|
|
|
189
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
166
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext);
|
|
190
167
|
vdoDownloadManager.query(query, statusList -> {
|
|
191
168
|
Log.i(TAG, statusList.size() + " results found");
|
|
192
169
|
successCallback.invoke(
|
|
@@ -199,7 +176,6 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
199
176
|
}
|
|
200
177
|
}
|
|
201
178
|
|
|
202
|
-
@ReactMethod
|
|
203
179
|
public void remove(ReadableArray deleteIds,
|
|
204
180
|
Callback errorCallback,
|
|
205
181
|
Callback successCallback) {
|
|
@@ -215,7 +191,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
215
191
|
}
|
|
216
192
|
}
|
|
217
193
|
|
|
218
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
194
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext);
|
|
219
195
|
vdoDownloadManager.remove(mediaIdsToDelete);
|
|
220
196
|
successCallback.invoke();
|
|
221
197
|
} catch (RuntimeException e) {
|
|
@@ -224,7 +200,6 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
224
200
|
}
|
|
225
201
|
}
|
|
226
202
|
|
|
227
|
-
@ReactMethod
|
|
228
203
|
public void stop(ReadableArray stopIds,
|
|
229
204
|
Callback errorCallback,
|
|
230
205
|
Callback successCallback) {
|
|
@@ -240,7 +215,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
240
215
|
}
|
|
241
216
|
}
|
|
242
217
|
|
|
243
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
218
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext);
|
|
244
219
|
vdoDownloadManager.stopDownloads(mediaIdsToStop);
|
|
245
220
|
successCallback.invoke();
|
|
246
221
|
} catch (RuntimeException e) {
|
|
@@ -249,7 +224,6 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
249
224
|
}
|
|
250
225
|
}
|
|
251
226
|
|
|
252
|
-
@ReactMethod
|
|
253
227
|
public void resume(ReadableArray resumeIds,
|
|
254
228
|
Callback errorCallback,
|
|
255
229
|
Callback successCallback) {
|
|
@@ -265,7 +239,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
265
239
|
}
|
|
266
240
|
}
|
|
267
241
|
|
|
268
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
242
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext);
|
|
269
243
|
vdoDownloadManager.resumeDownloads(mediaIdsToResume);
|
|
270
244
|
successCallback.invoke();
|
|
271
245
|
} catch (RuntimeException e) {
|
|
@@ -274,18 +248,17 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
274
248
|
}
|
|
275
249
|
}
|
|
276
250
|
|
|
277
|
-
@ReactMethod
|
|
278
251
|
public void isExpired(String mediaId,
|
|
279
252
|
Callback errorCallback,
|
|
280
253
|
Callback successCallback) {
|
|
281
254
|
try {
|
|
282
255
|
VdoDownloadManager.Query query = new VdoDownloadManager.Query();
|
|
283
256
|
query.setFilterByMediaId(mediaId);
|
|
284
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
257
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext);
|
|
285
258
|
vdoDownloadManager.query(query, statusList -> {
|
|
286
259
|
Log.i(TAG, statusList.size() + " results found");
|
|
287
260
|
if (statusList.size() > 0) {
|
|
288
|
-
boolean isExpired = statusList.get(0).isExpired(
|
|
261
|
+
boolean isExpired = statusList.get(0).isExpired(reactApplicationContext);
|
|
289
262
|
successCallback.invoke(
|
|
290
263
|
isExpired
|
|
291
264
|
);
|
|
@@ -303,32 +276,32 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
303
276
|
|
|
304
277
|
@Override
|
|
305
278
|
public void onQueued(String mediaId, DownloadStatus downloadStatus) {
|
|
306
|
-
sendEvent(
|
|
279
|
+
sendEvent(reactApplicationContext, "onQueued", mediaId, downloadStatus);
|
|
307
280
|
}
|
|
308
281
|
|
|
309
282
|
@Override
|
|
310
283
|
public void onChanged(String mediaId, DownloadStatus downloadStatus) {
|
|
311
|
-
sendEvent(
|
|
284
|
+
sendEvent(reactApplicationContext, "onChanged", mediaId, downloadStatus);
|
|
312
285
|
}
|
|
313
286
|
|
|
314
287
|
@Override
|
|
315
288
|
public void onCompleted(String mediaId, DownloadStatus downloadStatus) {
|
|
316
|
-
sendEvent(
|
|
289
|
+
sendEvent(reactApplicationContext, "onCompleted", mediaId, downloadStatus);
|
|
317
290
|
}
|
|
318
291
|
|
|
319
292
|
@Override
|
|
320
293
|
public void onFailed(String mediaId, DownloadStatus downloadStatus) {
|
|
321
|
-
sendEvent(
|
|
294
|
+
sendEvent(reactApplicationContext, "onFailed", mediaId, downloadStatus);
|
|
322
295
|
}
|
|
323
296
|
|
|
324
297
|
@Override
|
|
325
298
|
public void onDeleted(String mediaId) {
|
|
326
|
-
sendEvent(
|
|
299
|
+
sendEvent(reactApplicationContext, "onDeleted", mediaId, null);
|
|
327
300
|
}
|
|
328
301
|
|
|
329
302
|
// Private
|
|
330
303
|
|
|
331
|
-
|
|
304
|
+
public void enqueueDownload(String nativeId,
|
|
332
305
|
ReadableMap requestOptions,
|
|
333
306
|
EnqueueFailureCallback errorCallback,
|
|
334
307
|
Callback successCallback) {
|
|
@@ -352,7 +325,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
352
325
|
// Obtain download location
|
|
353
326
|
String downloadLocation;
|
|
354
327
|
try {
|
|
355
|
-
downloadLocation = getDownloadLocation(
|
|
328
|
+
downloadLocation = getDownloadLocation(reactApplicationContext);
|
|
356
329
|
} catch (RuntimeException e) {
|
|
357
330
|
Log.e(TAG, "download location could not be obtained: " + Log.getStackTraceString(e));
|
|
358
331
|
errorCallback.invoke(e.getClass().getName(), e.getMessage());
|
|
@@ -365,7 +338,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
365
338
|
// Build a DownloadRequest
|
|
366
339
|
DownloadRequest request = new DownloadRequest.Builder(downloadSelections).build();
|
|
367
340
|
|
|
368
|
-
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(
|
|
341
|
+
VdoDownloadManager vdoDownloadManager = VdoDownloadManager.getInstance(reactApplicationContext, downloadLocation);
|
|
369
342
|
|
|
370
343
|
// Enqueue request to VdoDownloadManager for download
|
|
371
344
|
try {
|
|
@@ -419,7 +392,7 @@ public class VdoDownloadModule extends ReactContextBaseJavaModule implements Vdo
|
|
|
419
392
|
/**
|
|
420
393
|
* Helper class to enforce enqueue failure callback arguments.
|
|
421
394
|
*/
|
|
422
|
-
|
|
395
|
+
public static class EnqueueFailureCallback {
|
|
423
396
|
private final Callback errorCallback;
|
|
424
397
|
|
|
425
398
|
EnqueueFailureCallback(Callback errorCallback) {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
package com.vdocipher.rnbridge;
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.StringDef;
|
|
4
|
+
import android.util.Log;
|
|
4
5
|
import android.view.View;
|
|
5
6
|
|
|
6
7
|
import com.facebook.react.bridge.Arguments;
|
|
7
8
|
import com.facebook.react.bridge.ReactContext;
|
|
8
9
|
import com.facebook.react.bridge.WritableArray;
|
|
9
10
|
import com.facebook.react.bridge.WritableMap;
|
|
10
|
-
import com.facebook.react.uimanager.
|
|
11
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
12
|
+
import com.facebook.react.uimanager.events.Event;
|
|
13
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
11
14
|
import com.vdocipher.aegis.media.ErrorDescription;
|
|
12
15
|
import com.vdocipher.aegis.media.MediaInfo;
|
|
13
16
|
import com.vdocipher.aegis.media.Track;
|
|
@@ -18,6 +21,7 @@ import java.lang.annotation.Retention;
|
|
|
18
21
|
import java.lang.annotation.RetentionPolicy;
|
|
19
22
|
|
|
20
23
|
class VdoEventEmitter {
|
|
24
|
+
private static final String TAG = "VdoEventEmitter";
|
|
21
25
|
private static final String EVENT_INIT_SUCCESS = "onInitSuccess";
|
|
22
26
|
private static final String EVENT_INIT_FAILURE = "onInitFailure";
|
|
23
27
|
private static final String EVENT_LOADING = "onVdoLoading";
|
|
@@ -30,7 +34,6 @@ class VdoEventEmitter {
|
|
|
30
34
|
private static final String EVENT_TRACKS_CHANGED = "onVdoTracksChanged";
|
|
31
35
|
private static final String EVENT_MEDIA_ENDED = "onVdoMediaEnded";
|
|
32
36
|
private static final String EVENT_ERROR = "onVdoError";
|
|
33
|
-
private static final String EVENT_PLAYBACK_PROPERTIES = "onVdoPlaybackProperties";
|
|
34
37
|
private static final String EVENT_ENTER_FULLSCREEN = "onVdoEnterFullscreen";
|
|
35
38
|
private static final String EVENT_EXIT_FULLSCREEN = "onVdoExitFullscreen";
|
|
36
39
|
private static final String EVENT_PICTURE_IN_PICTURE_MODE_CHANGED ="onVdoPictureInPictureModeChanged";
|
|
@@ -44,7 +47,6 @@ class VdoEventEmitter {
|
|
|
44
47
|
EVENT_PLAYBACK_SPEED_CHANGED, EVENT_TRACKS_CHANGED,
|
|
45
48
|
EVENT_MEDIA_ENDED,
|
|
46
49
|
EVENT_ERROR,
|
|
47
|
-
EVENT_PLAYBACK_PROPERTIES,
|
|
48
50
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
49
51
|
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED
|
|
50
52
|
};
|
|
@@ -57,7 +59,6 @@ class VdoEventEmitter {
|
|
|
57
59
|
EVENT_PLAYBACK_SPEED_CHANGED, EVENT_TRACKS_CHANGED,
|
|
58
60
|
EVENT_MEDIA_ENDED,
|
|
59
61
|
EVENT_ERROR,
|
|
60
|
-
EVENT_PLAYBACK_PROPERTIES,
|
|
61
62
|
EVENT_ENTER_FULLSCREEN, EVENT_EXIT_FULLSCREEN,
|
|
62
63
|
EVENT_PICTURE_IN_PICTURE_MODE_CHANGED})
|
|
63
64
|
@interface VdoEvent {}
|
|
@@ -79,15 +80,15 @@ class VdoEventEmitter {
|
|
|
79
80
|
|
|
80
81
|
private static final String EVENT_PROP_ERROR_DESCRIPTION = "errorDescription";
|
|
81
82
|
|
|
82
|
-
private final
|
|
83
|
-
private
|
|
83
|
+
private final ReactContext reactContext;
|
|
84
|
+
private View view;
|
|
84
85
|
|
|
85
86
|
VdoEventEmitter(ReactContext context) {
|
|
86
|
-
|
|
87
|
+
this.reactContext = context;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
void
|
|
90
|
-
this.
|
|
90
|
+
void setView(View view) {
|
|
91
|
+
this.view = view;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
void initSuccess(boolean restored) {
|
|
@@ -190,14 +191,47 @@ class VdoEventEmitter {
|
|
|
190
191
|
receiveEvent(EVENT_PICTURE_IN_PICTURE_MODE_CHANGED, event);
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
void playbackProperties(long totalPlayed, long totalCovered) {
|
|
194
|
-
WritableMap event = Arguments.createMap();
|
|
195
|
-
event.putInt("totalPlayed", (int)totalPlayed);
|
|
196
|
-
event.putInt("totalCovered", (int)totalCovered);
|
|
197
|
-
receiveEvent(EVENT_PLAYBACK_PROPERTIES, event);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
194
|
private void receiveEvent(@VdoEvent String type, WritableMap event) {
|
|
201
|
-
|
|
195
|
+
View v = this.view;
|
|
196
|
+
if (v == null) {
|
|
197
|
+
Log.d(TAG, "No view set; dropped event: " + type);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
int viewId = v.getId();
|
|
201
|
+
EventDispatcher dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, viewId);
|
|
202
|
+
if (dispatcher != null) {
|
|
203
|
+
int surfaceId = UIManagerHelper.getSurfaceId(v);
|
|
204
|
+
dispatcher.dispatchEvent(new VdoViewEvent(surfaceId, viewId, type,
|
|
205
|
+
event != null ? event : Arguments.createMap()));
|
|
206
|
+
} else {
|
|
207
|
+
Log.d(TAG, "No EventDispatcher for viewId=" + viewId + "; dropped event: " + type);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private static class VdoViewEvent extends Event<VdoViewEvent> {
|
|
212
|
+
private final String eventName;
|
|
213
|
+
private final WritableMap eventData;
|
|
214
|
+
|
|
215
|
+
VdoViewEvent(int surfaceId, int viewId, String eventName, WritableMap eventData) {
|
|
216
|
+
super(surfaceId, viewId);
|
|
217
|
+
this.eventName = eventName;
|
|
218
|
+
this.eventData = eventData;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Override
|
|
222
|
+
public String getEventName() {
|
|
223
|
+
return eventName;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@Override
|
|
227
|
+
public WritableMap getEventData() {
|
|
228
|
+
return eventData;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Every player event matters (state, tracks, errors…); don't let frames coalesce/drop them.
|
|
232
|
+
@Override
|
|
233
|
+
public boolean canCoalesce() {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
202
236
|
}
|
|
203
237
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.vdocipher.rnbridge;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.Callback;
|
|
5
|
+
|
|
6
|
+
public class VdoPlayerModuleImpl {
|
|
7
|
+
private static final String TAG = "VdoPlayerModule";
|
|
8
|
+
public static final String NAME = "VdoPlayer";
|
|
9
|
+
|
|
10
|
+
private final PlayerViewRegistry registry;
|
|
11
|
+
|
|
12
|
+
public VdoPlayerModuleImpl(ReactApplicationContext reactContext, PlayerViewRegistry registry) {
|
|
13
|
+
this.registry = registry;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void getPlaybackPropertiesV2(Callback callback) {
|
|
17
|
+
ReactVdoPlayerView playerView = registry.getPlayerView();
|
|
18
|
+
ReactVdoPlayerUIView playerUIView = registry.getPlayerUIView();
|
|
19
|
+
if (playerView == null && playerUIView == null) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (playerView != null) {
|
|
23
|
+
playerView.getPlaybackPropertiesV2(callback);
|
|
24
|
+
} else {
|
|
25
|
+
playerUIView.getPlaybackPropertiesV2(callback);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -15,21 +15,16 @@ import static com.vdocipher.rnbridge.Constants.VDO_PLAYBACK_MODE;
|
|
|
15
15
|
import android.content.Context;
|
|
16
16
|
import android.content.SharedPreferences;
|
|
17
17
|
|
|
18
|
-
public class
|
|
18
|
+
public class VdoPlayerSettingsModuleImpl {
|
|
19
19
|
private static final String TAG = "VdoPlayerSettingsModule";
|
|
20
|
+
public static final String NAME = "VdoPlayerSettings";
|
|
20
21
|
private ReactApplicationContext context;
|
|
21
22
|
|
|
22
|
-
@Override
|
|
23
|
-
public String getName() {
|
|
24
|
-
return "VdoPlayerSettings";
|
|
25
|
-
}
|
|
26
23
|
|
|
27
|
-
public
|
|
28
|
-
super(reactContext);
|
|
24
|
+
public VdoPlayerSettingsModuleImpl(ReactApplicationContext reactContext) {
|
|
29
25
|
context = reactContext;
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
@ReactMethod()
|
|
33
28
|
public void applySettings(ReadableMap playerSettings) {
|
|
34
29
|
|
|
35
30
|
String playbackMode = playerSettings.hasKey("vdoPlaybackModeAndroid") ?
|
|
@@ -12,21 +12,15 @@ import com.vdocipher.aegis.player.cache.VdoPreCacheManager;
|
|
|
12
12
|
import android.content.Context;
|
|
13
13
|
import android.content.SharedPreferences;
|
|
14
14
|
|
|
15
|
-
public class
|
|
15
|
+
public class VdoPreCacheManagerModuleImpl {
|
|
16
16
|
private static final String TAG = "VdoPlayerSettingsModule";
|
|
17
|
+
public static final String NAME = "VdoPreCacheManager";
|
|
17
18
|
private ReactApplicationContext context;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
public String getName() {
|
|
21
|
-
return "VdoPreCacheManager";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public VdoPreCacheManagerModule(ReactApplicationContext reactContext) {
|
|
25
|
-
super(reactContext);
|
|
20
|
+
public VdoPreCacheManagerModuleImpl(ReactApplicationContext reactContext) {
|
|
26
21
|
context = reactContext;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
@ReactMethod()
|
|
30
24
|
public void cacheVideo(ReadableMap preCacheSettings) {
|
|
31
25
|
|
|
32
26
|
String mediaId = preCacheSettings.hasKey("mediaId") ?
|
|
@@ -52,7 +46,6 @@ public class VdoPreCacheManagerModule extends ReactContextBaseJavaModule {
|
|
|
52
46
|
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
@ReactMethod()
|
|
56
49
|
public void clearCache() {
|
|
57
50
|
VdoPreCacheManager videoPreCache = VdoPreCacheManager.getInstance(context);
|
|
58
51
|
videoPreCache.clearCache();
|
|
@@ -14,30 +14,19 @@ import android.graphics.Color;
|
|
|
14
14
|
import static com.vdocipher.rnbridge.Utils.getTechOverride;
|
|
15
15
|
import java.util.HashMap;
|
|
16
16
|
|
|
17
|
-
public class
|
|
17
|
+
public class VdocipherRnBridgeModuleImpl {
|
|
18
|
+
|
|
19
|
+
public static final String NAME = "VdocipherRnBridge";
|
|
18
20
|
|
|
19
21
|
private final ReactApplicationContext reactContext;
|
|
20
22
|
|
|
21
|
-
public
|
|
22
|
-
super(reactContext);
|
|
23
|
+
public VdocipherRnBridgeModuleImpl(ReactApplicationContext reactContext) {
|
|
23
24
|
this.reactContext = reactContext;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
@Override
|
|
27
|
-
public String getName() {
|
|
28
|
-
return "VdocipherRnBridge";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@ReactMethod
|
|
32
|
-
public void hello() {
|
|
33
|
-
android.widget.Toast.makeText(getReactApplicationContext(), "Hello", android.widget.Toast.LENGTH_SHORT).show();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
27
|
// todo error event handling
|
|
37
|
-
|
|
38
|
-
public void startVideoScreen(ReadableMap embedParams, boolean setPictureInPictureSupport) {
|
|
28
|
+
public void startVideoScreen(ReadableMap embedParams, boolean setPictureInPictureSupport, Activity currentActivity) {
|
|
39
29
|
ReadableMap embedInfo = embedParams.getMap("embedInfo");
|
|
40
|
-
Activity currentActivity = getCurrentActivity();
|
|
41
30
|
if (currentActivity == null) {
|
|
42
31
|
android.util.Log.e("VdoRnBridgeModule", "Current Activity context could not be obtained.");
|
|
43
32
|
} else {
|
|
@@ -11,42 +11,28 @@ import com.facebook.react.uimanager.ViewManager;
|
|
|
11
11
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
12
12
|
|
|
13
13
|
public class VdocipherRnBridgePackage implements ReactPackage {
|
|
14
|
-
private
|
|
15
|
-
private ReactVdoPlayerUIViewManager vdoPlayerUIViewManager;
|
|
14
|
+
private final PlayerViewRegistry registry = new PlayerViewRegistry();
|
|
16
15
|
|
|
17
16
|
@Override
|
|
18
17
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
new VdocipherRnBridgeModule(reactContext),
|
|
27
|
-
new VdoDownloadModule(reactContext),
|
|
28
|
-
new TrackSelectionModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager),
|
|
29
|
-
new VdoPlayerModule(reactContext, vdoPlayerViewManager, vdoPlayerUIViewManager),
|
|
30
|
-
new VdoPlayerSettingsModule(reactContext),
|
|
31
|
-
new VdoPreCacheManagerModule(reactContext));
|
|
18
|
+
return Arrays.<NativeModule>asList(
|
|
19
|
+
new VdocipherRnBridgeModule(reactContext),
|
|
20
|
+
new VdoDownloadModule(reactContext),
|
|
21
|
+
new TrackSelectionModule(reactContext, registry),
|
|
22
|
+
new VdoPlayerModule(reactContext, registry),
|
|
23
|
+
new VdoPlayerSettingsModule(reactContext),
|
|
24
|
+
new VdoPreCacheManagerModule(reactContext));
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
// Deprecated from RN 0.47
|
|
35
28
|
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
36
|
-
|
|
29
|
+
return Collections.emptyList();
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
@Override
|
|
40
33
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (vdoPlayerUIViewManager == null) {
|
|
45
|
-
vdoPlayerUIViewManager = new ReactVdoPlayerUIViewManager();
|
|
46
|
-
}
|
|
47
|
-
return Arrays.<ViewManager>asList(
|
|
48
|
-
vdoPlayerUIViewManager,
|
|
49
|
-
vdoPlayerViewManager
|
|
50
|
-
);
|
|
34
|
+
return Arrays.<ViewManager>asList(
|
|
35
|
+
new ReactVdoPlayerUIViewManager(reactContext, registry),
|
|
36
|
+
new ReactVdoPlayerViewManager(reactContext, registry));
|
|
51
37
|
}
|
|
52
|
-
}
|
|
38
|
+
}
|