vdocipher-rn-bridge 1.11.0 → 1.12.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.
@@ -0,0 +1,86 @@
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 TrackSelectionModule extends ReactContextBaseJavaModule implements ReactVdoPlayerViewManager.Callback {
12
+ private static final String TAG = "TrackSelectionModule";
13
+
14
+ private ReactVdoPlayerView vdoPlayerView;
15
+
16
+ @Override
17
+ public String getName() {
18
+ return "TrackSelection";
19
+ }
20
+
21
+ public TrackSelectionModule(ReactApplicationContext reactContext, ReactVdoPlayerViewManager vdoPlayerViewManager) {
22
+ super(reactContext);
23
+ if (vdoPlayerViewManager != null) {
24
+ vdoPlayerViewManager.setCallback(this);
25
+ }
26
+ }
27
+
28
+ @ReactMethod
29
+ public void isAdaptive(com.facebook.react.bridge.Callback callback) {
30
+ if (vdoPlayerView == null) {
31
+ return;
32
+ }
33
+ vdoPlayerView.isAdaptive(callback);
34
+ }
35
+
36
+ @ReactMethod
37
+ public void getVideoQualities(com.facebook.react.bridge.Callback callback) {
38
+ if (vdoPlayerView == null) {
39
+ return;
40
+ }
41
+ vdoPlayerView.getVideoQualities(callback);
42
+ }
43
+
44
+ @ReactMethod
45
+ public void getSelectedVideoQuality(com.facebook.react.bridge.Callback callback) {
46
+ if (vdoPlayerView == null) {
47
+ return;
48
+ }
49
+ vdoPlayerView.getSelectedVideoQuality(callback);
50
+ }
51
+
52
+ @ReactMethod
53
+ public void getSelectedAudioQuality(com.facebook.react.bridge.Callback callback) {
54
+ if (vdoPlayerView == null) {
55
+ return;
56
+ }
57
+ vdoPlayerView.getSelectedAudioQuality(callback);
58
+ }
59
+
60
+ @ReactMethod
61
+ public void getCaptionLanguages(com.facebook.react.bridge.Callback callback) {
62
+ if (vdoPlayerView == null) {
63
+ return;
64
+ }
65
+ vdoPlayerView.getCaptionLanguages(callback);
66
+ }
67
+
68
+ @ReactMethod
69
+ public void getSelectedCaptionLanguage(com.facebook.react.bridge.Callback callback) {
70
+ if (vdoPlayerView == null) {
71
+ return;
72
+ }
73
+ vdoPlayerView.getSelectedCaptionLanguage(callback);
74
+ }
75
+
76
+ @ReactMethod()
77
+ public void getDuration(com.facebook.react.bridge.Callback callback) {
78
+ vdoPlayerView.getDuration(callback);
79
+ }
80
+
81
+ @Override
82
+ public void onVideoPlayerViewInitialised(ReactVdoPlayerView vdoPlayerView) {
83
+ this.vdoPlayerView = vdoPlayerView;
84
+ }
85
+
86
+ }
@@ -35,6 +35,8 @@ public class Utils {
35
35
  private static final String EVENT_PROP_TRACK_BITRATE = "bitrate";
36
36
  private static final String EVENT_PROP_TRACK_WIDTH = "width";
37
37
  private static final String EVENT_PROP_TRACK_HEIGHT = "height";
38
+ private static final String EVENT_PROP_TRACK_LABEL = "label";
39
+
38
40
 
39
41
  private static final String EVENT_PROP_DOWNLOAD_STATUS_MEDIA_INFO = "mediaInfo";
40
42
  private static final String EVENT_PROP_DOWNLOAD_STATUS_LOCAL_STORAGE_FOLDER = "localStorageFolder";
@@ -111,9 +113,90 @@ public class Utils {
111
113
  trackMap.putInt(EVENT_PROP_TRACK_BITRATE, track.bitrate);
112
114
  trackMap.putInt(EVENT_PROP_TRACK_WIDTH, track.width);
113
115
  trackMap.putInt(EVENT_PROP_TRACK_HEIGHT, track.height);
116
+ trackMap.putString(EVENT_PROP_TRACK_LABEL, track.label);
117
+ return trackMap;
118
+ }
119
+
120
+ public static WritableArray makeAvailableTrackMapArray(Track[] availableTracks, int type) {
121
+ WritableArray trackArray = Arguments.createArray();
122
+
123
+ for (Track track : availableTracks) {
124
+ if (track.type == type && type == Track.TYPE_VIDEO) {
125
+ trackArray.pushMap(makeAudioVideoTrackMap(track));
126
+ } else if (track.type == type && type == Track.TYPE_CAPTIONS) {
127
+ trackArray.pushMap(makeLanguagesMap(track));
128
+ }
129
+ }
130
+ return trackArray;
131
+ }
132
+
133
+ public static WritableMap makeSelectedVideoTrackMap(Track[] selectedTracks) {
134
+ WritableMap trackMap = Arguments.createMap();
135
+
136
+ int selectedVideoCount = 0;
137
+ for (Track track : selectedTracks) {
138
+ if (track.type == Track.TYPE_VIDEO) {
139
+ trackMap = makeAudioVideoTrackMap(track);
140
+ selectedVideoCount++;
141
+ if (selectedVideoCount > 1) {
142
+ return null;
143
+ }
144
+ }
145
+ }
146
+
114
147
  return trackMap;
115
148
  }
116
149
 
150
+ public static WritableMap makeSelectedAudioTrackMap(Track[] selectedTracks) {
151
+ for (Track track : selectedTracks) {
152
+ if (track.type == Track.TYPE_AUDIO) {
153
+ return makeAudioVideoTrackMap(track);
154
+ }
155
+ }
156
+
157
+ return Arguments.createMap();
158
+ }
159
+
160
+ public static WritableMap makeSelectedCaptionTrackMap(Track[] selectedTracks) {
161
+ for (Track track : selectedTracks) {
162
+ if (track.type == Track.TYPE_CAPTIONS) {
163
+ return makeLanguagesMap(track);
164
+ }
165
+ }
166
+
167
+ return null;
168
+ }
169
+
170
+ public static WritableMap makeAudioVideoTrackMap(Track track) {
171
+ WritableMap trackMap = Arguments.createMap();
172
+ trackMap.putInt(EVENT_PROP_TRACK_ID, track.id);
173
+ trackMap.putInt(EVENT_PROP_TRACK_BITRATE, track.bitrate);
174
+ trackMap.putInt(EVENT_PROP_TRACK_WIDTH, track.width);
175
+ trackMap.putInt(EVENT_PROP_TRACK_HEIGHT, track.height);
176
+ return trackMap;
177
+ }
178
+
179
+ public static WritableMap makeLanguagesMap(Track track) {
180
+ WritableMap trackMap = Arguments.createMap();
181
+ trackMap.putInt(EVENT_PROP_TRACK_ID, track.id);
182
+ trackMap.putString(EVENT_PROP_TRACK_LANGUAGE, track.language);
183
+ trackMap.putString(EVENT_PROP_TRACK_LABEL, track.label);
184
+ return trackMap;
185
+ }
186
+
187
+ public static Track makeTrack(ReadableMap selectedTrackMap, Track[] availableTracks) {
188
+ int id = selectedTrackMap.getInt("id");
189
+
190
+ for (Track track : availableTracks) {
191
+ if (track.id == id) {
192
+ return track;
193
+ }
194
+ }
195
+
196
+ return null;
197
+
198
+ }
199
+
117
200
  public static WritableMap makeDownloadOptionsMap(DownloadOptions options) {
118
201
  WritableMap optionsMap = Arguments.createMap();
119
202
  optionsMap.putString(EVENT_PROP_MEDIA_INFO_ID, options.mediaId);
@@ -41,6 +41,8 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
41
41
  boolean offline = embedInfo.hasKey("offline") && embedInfo.getBoolean("offline");
42
42
  final VdoInitParams vdoParams;
43
43
  boolean enableAutoResume = embedInfo.hasKey("enableAutoResume") && embedInfo.getBoolean("enableAutoResume");
44
+ String preferredCaptionsLanguage = embedInfo.hasKey("preferredCaptionsLanguage") ?
45
+ embedInfo.getString("preferredCaptionsLanguage") : null;
44
46
 
45
47
  if (offline) {
46
48
  String mediaId = embedInfo.hasKey("mediaId") ? embedInfo.getString("mediaId") : null;
@@ -60,6 +62,9 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
60
62
  if (safetyNetApiKey != null) {
61
63
  builder.setSafetyNetApiKey(safetyNetApiKey);
62
64
  }
65
+ if (preferredCaptionsLanguage != null) {
66
+ builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
67
+ }
63
68
  vdoParams = builder.build();
64
69
  } else {
65
70
  String otp = embedInfo.hasKey("otp") ? embedInfo.getString("otp") : null;
@@ -84,8 +89,7 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
84
89
  .setAllowAdbDebugging(allowAdbDebugging)
85
90
  .setForceLowestBitrate(forceLowestBitrate)
86
91
  .setForceHighestSupportedBitrate(forceHighestSupportedBitrate)
87
- .setMaxVideoBitrateKbps(maxVideoBitrateKbps)
88
- .setPreferredCaptionsLanguage("en");
92
+ .setMaxVideoBitrateKbps(maxVideoBitrateKbps);
89
93
 
90
94
  if (enableAutoResume) {
91
95
  builder.enableAutoResume();
@@ -99,6 +103,9 @@ public class VdocipherRnBridgeModule extends ReactContextBaseJavaModule {
99
103
  if (safetyNetApiKey != null) {
100
104
  builder.setSafetyNetApiKey(safetyNetApiKey);
101
105
  }
106
+ if (preferredCaptionsLanguage != null) {
107
+ builder.setPreferredCaptionsLanguage(preferredCaptionsLanguage);
108
+ }
102
109
  vdoParams = builder.build();
103
110
  }
104
111
 
@@ -11,11 +11,17 @@ 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 ReactVdoPlayerViewManager vdoPlayerViewManager;
15
+
14
16
  @Override
15
17
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
18
+ if (vdoPlayerViewManager == null) {
19
+ vdoPlayerViewManager = new ReactVdoPlayerViewManager();
20
+ }
16
21
  return Arrays.<NativeModule>asList(
17
22
  new VdocipherRnBridgeModule(reactContext),
18
- new VdoDownloadModule(reactContext));
23
+ new VdoDownloadModule(reactContext),
24
+ new TrackSelectionModule(reactContext, vdoPlayerViewManager));
19
25
  }
20
26
 
21
27
  // Deprecated from RN 0.47
@@ -25,9 +31,12 @@ public class VdocipherRnBridgePackage implements ReactPackage {
25
31
 
26
32
  @Override
27
33
  public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
34
+ if (vdoPlayerViewManager == null) {
35
+ vdoPlayerViewManager = new ReactVdoPlayerViewManager();
36
+ }
28
37
  return Arrays.<ViewManager>asList(
29
- new ReactVdoPlayerViewManager(),
30
- new ReactVdoPlayerUIViewManager()
38
+ new ReactVdoPlayerUIViewManager(),
39
+ vdoPlayerViewManager
31
40
  );
32
41
  }
33
42
  }
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "vdocipher-rn-bridge",
3
- "version": "1.11.0",
3
+ "version": "1.12.1",
4
4
  "description": "React native bridge library that delegates to vdocipher native android SDK",
5
+ "homepage": "https://www.vdocipher.com/docs/mobile/react-native/getting-started/",
5
6
  "scripts": {
6
7
  "test": "echo \"Error: no test specified\" && exit 1"
7
8
  },
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/VdoCipher/vdocipher-react-native.git"
11
- },
12
9
  "keywords": [
13
10
  "react-native"
14
11
  ],