@jwplayer/jwplayer-react-native 1.0.3 → 1.1.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/README.md +33 -9
- package/RNJWPlayer.podspec +2 -2
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/build.gradle +10 -3
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerModule.java +279 -434
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java +86 -33
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerViewManager.java +7 -1
- package/android/src/main/java/com/jwplayer/rnjwplayer/Util.java +39 -2
- package/badges/version.svg +1 -1
- package/index.d.ts +21 -2
- package/index.js +38 -2
- package/ios/RNJWPlayer/RNJWPlayerView.swift +56 -6
- package/ios/RNJWPlayer/RNJWPlayerViewController.swift +14 -4
- package/ios/RNJWPlayer/RNJWPlayerViewManager.m +4 -1
- package/ios/RNJWPlayer/RNJWPlayerViewManager.swift +222 -167
- package/ios/RNJWPlayer.xcodeproj/project.pbxproj +4 -2
- package/package.json +1 -1
- package/jwplayer-jwplayer-react-native-1.0.3.tgz +0 -0
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
1
|
package com.jwplayer.rnjwplayer;
|
|
3
2
|
|
|
3
|
+
import android.os.Handler;
|
|
4
|
+
import android.os.Looper;
|
|
5
|
+
|
|
4
6
|
import com.facebook.react.bridge.Arguments;
|
|
5
7
|
import com.facebook.react.bridge.Promise;
|
|
6
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
10
|
import com.facebook.react.bridge.ReactMethod;
|
|
9
11
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
|
+
import com.facebook.react.bridge.UIManager;
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
10
14
|
import com.facebook.react.bridge.WritableArray;
|
|
11
15
|
import com.facebook.react.bridge.WritableMap;
|
|
12
16
|
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
13
17
|
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
14
18
|
import com.facebook.react.uimanager.UIBlock;
|
|
19
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
15
20
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
21
|
+
import com.facebook.react.uimanager.common.UIManagerType;
|
|
16
22
|
import com.jwplayer.pub.api.JWPlayer;
|
|
17
23
|
import com.jwplayer.pub.api.PlayerState;
|
|
18
24
|
import com.jwplayer.pub.api.configuration.PlayerConfig;
|
|
19
25
|
import com.jwplayer.pub.api.media.adaptive.QualityLevel;
|
|
20
26
|
import com.jwplayer.pub.api.media.audio.AudioTrack;
|
|
21
|
-
|
|
22
27
|
import java.util.List;
|
|
23
28
|
|
|
24
29
|
public class RNJWPlayerModule extends ReactContextBaseJavaModule {
|
|
@@ -38,541 +43,381 @@ public class RNJWPlayerModule extends ReactContextBaseJavaModule {
|
|
|
38
43
|
return TAG;
|
|
39
44
|
}
|
|
40
45
|
|
|
46
|
+
private RNJWPlayerView getPlayerView(int reactTag) {
|
|
47
|
+
int uiManagerType;
|
|
48
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
49
|
+
uiManagerType = UIManagerType.FABRIC;
|
|
50
|
+
} else {
|
|
51
|
+
uiManagerType = UIManagerType.DEFAULT;
|
|
52
|
+
}
|
|
53
|
+
UIManager uiManager = UIManagerHelper.getUIManager(mReactContext, uiManagerType);
|
|
54
|
+
if (uiManager != null) {
|
|
55
|
+
return (RNJWPlayerView) uiManager.resolveView(reactTag);
|
|
56
|
+
} else {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
@ReactMethod
|
|
42
62
|
public void loadPlaylist(final int reactTag, final ReadableArray playlistItems) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
player.setup(config);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
} catch (IllegalViewOperationException e) {
|
|
76
|
-
throw e;
|
|
77
|
-
}
|
|
63
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
64
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
65
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
66
|
+
JWPlayer player = playerView.mPlayerView.getPlayer();
|
|
67
|
+
|
|
68
|
+
PlayerConfig oldConfig = player.getConfig();
|
|
69
|
+
PlayerConfig config = new PlayerConfig.Builder()
|
|
70
|
+
.autostart(oldConfig.getAutostart())
|
|
71
|
+
.nextUpOffset(oldConfig.getNextUpOffset())
|
|
72
|
+
.repeat(oldConfig.getRepeat())
|
|
73
|
+
.relatedConfig(oldConfig.getRelatedConfig())
|
|
74
|
+
.displayDescription(oldConfig.getDisplayDescription())
|
|
75
|
+
.displayTitle(oldConfig.getDisplayTitle())
|
|
76
|
+
.advertisingConfig(oldConfig.getAdvertisingConfig())
|
|
77
|
+
.stretching(oldConfig.getStretching())
|
|
78
|
+
.uiConfig(oldConfig.getUiConfig())
|
|
79
|
+
.playlist(Util.createPlaylist(playlistItems))
|
|
80
|
+
.allowCrossProtocolRedirects(oldConfig.getAllowCrossProtocolRedirects())
|
|
81
|
+
.preload(oldConfig.getPreload())
|
|
82
|
+
.useTextureView(oldConfig.useTextureView())
|
|
83
|
+
.thumbnailPreview(oldConfig.getThumbnailPreview())
|
|
84
|
+
.mute(oldConfig.getMute())
|
|
85
|
+
.build();
|
|
86
|
+
|
|
87
|
+
player.setup(config);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
@ReactMethod
|
|
81
|
-
public void
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
player.setup(config);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
} catch (IllegalViewOperationException e) {
|
|
114
|
-
throw e;
|
|
115
|
-
}
|
|
93
|
+
public void loadPlaylistWithUrl(final int reactTag, final String playlistUrl) {
|
|
94
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
95
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
96
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
97
|
+
JWPlayer player = playerView.mPlayerView.getPlayer();
|
|
98
|
+
|
|
99
|
+
PlayerConfig oldConfig = player.getConfig();
|
|
100
|
+
PlayerConfig config = new PlayerConfig.Builder()
|
|
101
|
+
.autostart(oldConfig.getAutostart())
|
|
102
|
+
.nextUpOffset(oldConfig.getNextUpOffset())
|
|
103
|
+
.repeat(oldConfig.getRepeat())
|
|
104
|
+
.relatedConfig(oldConfig.getRelatedConfig())
|
|
105
|
+
.displayDescription(oldConfig.getDisplayDescription())
|
|
106
|
+
.displayTitle(oldConfig.getDisplayTitle())
|
|
107
|
+
.advertisingConfig(oldConfig.getAdvertisingConfig())
|
|
108
|
+
.stretching(oldConfig.getStretching())
|
|
109
|
+
.uiConfig(oldConfig.getUiConfig())
|
|
110
|
+
.playlistUrl(playlistUrl)
|
|
111
|
+
.allowCrossProtocolRedirects(oldConfig.getAllowCrossProtocolRedirects())
|
|
112
|
+
.preload(oldConfig.getPreload())
|
|
113
|
+
.useTextureView(oldConfig.useTextureView())
|
|
114
|
+
.thumbnailPreview(oldConfig.getThumbnailPreview())
|
|
115
|
+
.mute(oldConfig.getMute())
|
|
116
|
+
.build();
|
|
117
|
+
|
|
118
|
+
player.setup(config);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
@ReactMethod
|
|
119
124
|
public void play(final int reactTag) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
127
|
-
playerView.mPlayerView.getPlayer().play();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
} catch (IllegalViewOperationException e) {
|
|
132
|
-
throw e;
|
|
133
|
-
}
|
|
125
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
126
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
127
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
128
|
+
playerView.mPlayerView.getPlayer().play();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
134
131
|
}
|
|
135
132
|
|
|
136
133
|
@ReactMethod
|
|
137
134
|
public void toggleSpeed(final int reactTag) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (rate < 2) {
|
|
147
|
-
playerView.mPlayerView.getPlayer().setPlaybackRate(rate += 0.5);
|
|
148
|
-
} else {
|
|
149
|
-
playerView.mPlayerView.getPlayer().setPlaybackRate((float) 0.5);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
135
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
136
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
137
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
138
|
+
double rate = playerView.mPlayerView.getPlayer().getPlaybackRate();
|
|
139
|
+
if (rate < 2) {
|
|
140
|
+
playerView.mPlayerView.getPlayer().setPlaybackRate(rate += 0.5);
|
|
141
|
+
} else {
|
|
142
|
+
playerView.mPlayerView.getPlayer().setPlaybackRate((float) 0.5);
|
|
152
143
|
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
throw e;
|
|
156
|
-
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
157
146
|
}
|
|
158
147
|
|
|
159
148
|
@ReactMethod
|
|
160
149
|
public void togglePIP(final int reactTag) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (playerView.mPlayerView.getPlayer().isInPictureInPictureMode()) {
|
|
169
|
-
playerView.mPlayerView.getPlayer().exitPictureInPictureMode();
|
|
170
|
-
} else {
|
|
171
|
-
playerView.mPlayerView.getPlayer().enterPictureInPictureMode();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
150
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
151
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
152
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
153
|
+
if (playerView.mPlayerView.getPlayer().isInPictureInPictureMode()) {
|
|
154
|
+
playerView.mPlayerView.getPlayer().exitPictureInPictureMode();
|
|
155
|
+
} else {
|
|
156
|
+
playerView.mPlayerView.getPlayer().enterPictureInPictureMode();
|
|
174
157
|
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
throw e;
|
|
178
|
-
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
179
160
|
}
|
|
180
161
|
|
|
181
162
|
@ReactMethod
|
|
182
163
|
public void setSpeed(final int reactTag, final float speed) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
190
|
-
playerView.mPlayerView.getPlayer().setPlaybackRate(speed);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
} catch (IllegalViewOperationException e) {
|
|
195
|
-
throw e;
|
|
196
|
-
}
|
|
164
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
165
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
166
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
167
|
+
playerView.mPlayerView.getPlayer().setPlaybackRate(speed);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
197
170
|
}
|
|
198
171
|
|
|
199
|
-
|
|
200
172
|
@ReactMethod
|
|
201
173
|
public void getCurrentQuality(final int reactTag, final Promise promise) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
} else {
|
|
212
|
-
promise.reject("RNJW Error", "getCurrentQuality() Player is null");
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
} catch (IllegalViewOperationException e) {
|
|
217
|
-
throw e;
|
|
218
|
-
}
|
|
174
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
175
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
176
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
177
|
+
int quality = playerView.mPlayerView.getPlayer().getCurrentQuality();
|
|
178
|
+
promise.resolve(quality);
|
|
179
|
+
} else {
|
|
180
|
+
promise.reject("RNJW Error", "getCurrentQuality() Player is null");
|
|
181
|
+
}
|
|
182
|
+
});
|
|
219
183
|
}
|
|
220
184
|
|
|
221
185
|
@ReactMethod
|
|
222
186
|
public void setCurrentQuality(final int reactTag, final int index) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
230
|
-
playerView.mPlayerView.getPlayer().setCurrentQuality(index);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
} catch (IllegalViewOperationException e) {
|
|
235
|
-
throw e;
|
|
236
|
-
}
|
|
187
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
188
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
189
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
190
|
+
playerView.mPlayerView.getPlayer().setCurrentQuality(index);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
237
193
|
}
|
|
238
194
|
|
|
239
|
-
|
|
240
195
|
@ReactMethod
|
|
241
196
|
public void getQualityLevels(final int reactTag, final Promise promise) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
List<QualityLevel> qualityLevelsList = playerView.mPlayerView.getPlayer().getQualityLevels();
|
|
250
|
-
if (qualityLevelsList == null) { //if qualitylevels are null than pass empty array.
|
|
251
|
-
promise.resolve(null);
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
WritableArray qualityLevels = Arguments.createArray();
|
|
255
|
-
for (int i = 0; i < qualityLevelsList.size(); i++) {
|
|
256
|
-
WritableMap qualityLevel = Arguments.createMap();
|
|
257
|
-
QualityLevel level = qualityLevelsList.get(i);
|
|
258
|
-
qualityLevel.putInt("playListPosition", level.getPlaylistPosition());
|
|
259
|
-
qualityLevel.putInt("bitRate", level.getBitrate());
|
|
260
|
-
qualityLevel.putString("label", level.getLabel());
|
|
261
|
-
qualityLevel.putInt("height", level.getHeight());
|
|
262
|
-
qualityLevel.putInt("width", level.getWidth());
|
|
263
|
-
qualityLevel.putInt("index", level.getTrackIndex());
|
|
264
|
-
qualityLevels.pushMap(qualityLevel);
|
|
265
|
-
}
|
|
266
|
-
promise.resolve(qualityLevels);
|
|
267
|
-
} else {
|
|
268
|
-
promise.reject("RNJW Error", "getQualityLevels() Player is null");
|
|
269
|
-
}
|
|
197
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
198
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
199
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
200
|
+
List<QualityLevel> qualityLevelsList = playerView.mPlayerView.getPlayer().getQualityLevels();
|
|
201
|
+
if (qualityLevelsList == null) { //if qualitylevels are null than pass empty array.
|
|
202
|
+
promise.resolve(null);
|
|
203
|
+
return;
|
|
270
204
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
205
|
+
WritableArray qualityLevels = Arguments.createArray();
|
|
206
|
+
for (int i = 0; i < qualityLevelsList.size(); i++) {
|
|
207
|
+
WritableMap qualityLevel = Arguments.createMap();
|
|
208
|
+
QualityLevel level = qualityLevelsList.get(i);
|
|
209
|
+
qualityLevel.putInt("playListPosition", level.getPlaylistPosition());
|
|
210
|
+
qualityLevel.putInt("bitRate", level.getBitrate());
|
|
211
|
+
qualityLevel.putString("label", level.getLabel());
|
|
212
|
+
qualityLevel.putInt("height", level.getHeight());
|
|
213
|
+
qualityLevel.putInt("width", level.getWidth());
|
|
214
|
+
qualityLevel.putInt("index", level.getTrackIndex());
|
|
215
|
+
qualityLevels.pushMap(qualityLevel);
|
|
216
|
+
}
|
|
217
|
+
promise.resolve(qualityLevels);
|
|
218
|
+
} else {
|
|
219
|
+
promise.reject("RNJW Error", "getQualityLevels() Player is null");
|
|
220
|
+
}
|
|
221
|
+
});
|
|
275
222
|
}
|
|
276
223
|
|
|
277
224
|
@ReactMethod
|
|
278
225
|
public void pause(final int reactTag) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
286
|
-
if (!playerView.getIsCastActive()) {
|
|
287
|
-
playerView.mPlayerView.getPlayer().pause();
|
|
288
|
-
playerView.userPaused = true;
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
}
|
|
226
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
227
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
228
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
229
|
+
if (!playerView.getIsCastActive()) {
|
|
230
|
+
playerView.mPlayerView.getPlayer().pause();
|
|
231
|
+
playerView.userPaused = true;
|
|
292
232
|
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
throw e;
|
|
296
|
-
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
297
235
|
}
|
|
298
236
|
|
|
299
237
|
@ReactMethod
|
|
300
238
|
public void stop(final int reactTag) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
308
|
-
if (!playerView.getIsCastActive()) {
|
|
309
|
-
playerView.mPlayerView.getPlayer().stop();
|
|
310
|
-
playerView.userPaused = true;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
239
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
240
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
241
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
242
|
+
if (!playerView.getIsCastActive()) {
|
|
243
|
+
playerView.mPlayerView.getPlayer().stop();
|
|
244
|
+
playerView.userPaused = true;
|
|
313
245
|
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
throw e;
|
|
317
|
-
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
318
248
|
}
|
|
319
249
|
|
|
320
250
|
@ReactMethod
|
|
321
251
|
public void seekTo(final int reactTag, final double time) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
329
|
-
playerView.mPlayerView.getPlayer().seek(time);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
} catch (IllegalViewOperationException e) {
|
|
334
|
-
throw e;
|
|
335
|
-
}
|
|
252
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
253
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
254
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
255
|
+
playerView.mPlayerView.getPlayer().seek(time);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
336
258
|
}
|
|
337
259
|
|
|
338
260
|
@ReactMethod
|
|
339
261
|
public void setPlaylistIndex(final int reactTag, final int index) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
347
|
-
playerView.mPlayerView.getPlayer().playlistItem(index);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
} catch (IllegalViewOperationException e) {
|
|
352
|
-
throw e;
|
|
353
|
-
}
|
|
262
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
263
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
264
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
265
|
+
playerView.mPlayerView.getPlayer().playlistItem(index);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
354
268
|
}
|
|
355
269
|
|
|
356
270
|
@ReactMethod
|
|
357
271
|
public void setControls(final int reactTag, final boolean show) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
365
|
-
playerView.mPlayerView.getPlayer().setControls(show);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
} catch (IllegalViewOperationException e) {
|
|
370
|
-
throw e;
|
|
371
|
-
}
|
|
272
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
273
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
274
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
275
|
+
playerView.mPlayerView.getPlayer().setControls(show);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
372
278
|
}
|
|
373
279
|
|
|
374
280
|
@ReactMethod
|
|
375
281
|
public void position(final int reactTag, final Promise promise) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
} else {
|
|
385
|
-
promise.reject("RNJW Error", "Player is null");
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
} catch (IllegalViewOperationException e) {
|
|
390
|
-
promise.reject("RNJW Error", e);
|
|
391
|
-
}
|
|
282
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
283
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
284
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
285
|
+
promise.resolve((Double.valueOf(playerView.mPlayerView.getPlayer().getPosition()).intValue()));
|
|
286
|
+
} else {
|
|
287
|
+
promise.reject("RNJW Error", "Player is null");
|
|
288
|
+
}
|
|
289
|
+
});
|
|
392
290
|
}
|
|
393
291
|
|
|
394
292
|
@ReactMethod
|
|
395
293
|
public void state(final int reactTag, final Promise promise) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
} else {
|
|
406
|
-
promise.reject("RNJW Error", "Player is null");
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
} catch (IllegalViewOperationException e) {
|
|
411
|
-
promise.reject("RNJW Error", e);
|
|
412
|
-
}
|
|
294
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
295
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
296
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
297
|
+
PlayerState playerState = playerView.mPlayerView.getPlayer().getState();
|
|
298
|
+
promise.resolve(stateToInt(playerState));
|
|
299
|
+
} else {
|
|
300
|
+
promise.reject("RNJW Error", "Player is null");
|
|
301
|
+
}
|
|
302
|
+
});
|
|
413
303
|
}
|
|
414
304
|
|
|
415
305
|
@ReactMethod
|
|
416
306
|
public void setFullscreen(final int reactTag, final boolean fullscreen) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (playerView != null && playerView.mPlayerView != null) {
|
|
424
|
-
playerView.mPlayerView.getPlayer().setFullscreen(fullscreen, fullscreen);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
} catch (IllegalViewOperationException e) {
|
|
429
|
-
throw e;
|
|
430
|
-
}
|
|
307
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
308
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
309
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
310
|
+
playerView.mPlayerView.getPlayer().setFullscreen(fullscreen, fullscreen);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
431
313
|
}
|
|
432
314
|
|
|
433
315
|
@ReactMethod
|
|
434
316
|
public void setVolume(final int reactTag, final int volume) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
} catch (IllegalViewOperationException e) {
|
|
444
|
-
throw e;
|
|
445
|
-
}
|
|
317
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
318
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
319
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
320
|
+
playerView.mPlayerView.getPlayer().setVolume(volume);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
446
323
|
}
|
|
447
324
|
|
|
448
325
|
@ReactMethod
|
|
449
326
|
public void getAudioTracks(final int reactTag, final Promise promise) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
audioTrack.putString("groupId", track.getGroupId());
|
|
466
|
-
audioTrack.putBoolean("defaultTrack", track.isDefaultTrack());
|
|
467
|
-
audioTrack.putBoolean("autoSelect", track.isAutoSelect());
|
|
468
|
-
audioTracks.pushMap(audioTrack);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
promise.resolve(audioTracks);
|
|
472
|
-
} else {
|
|
473
|
-
promise.reject("RNJW Error", "Player is null");
|
|
327
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
328
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
329
|
+
if (playerView != null && playerView.mPlayer != null) {
|
|
330
|
+
List<AudioTrack> audioTrackList = playerView.mPlayer.getAudioTracks();
|
|
331
|
+
WritableArray audioTracks = Arguments.createArray();
|
|
332
|
+
if (audioTrackList != null) {
|
|
333
|
+
for (int i = 0; i < audioTrackList.size(); i++) {
|
|
334
|
+
WritableMap audioTrack = Arguments.createMap();
|
|
335
|
+
AudioTrack track = audioTrackList.get(i);
|
|
336
|
+
audioTrack.putString("name", track.getName());
|
|
337
|
+
audioTrack.putString("language", track.getLanguage());
|
|
338
|
+
audioTrack.putString("groupId", track.getGroupId());
|
|
339
|
+
audioTrack.putBoolean("defaultTrack", track.isDefaultTrack());
|
|
340
|
+
audioTrack.putBoolean("autoSelect", track.isAutoSelect());
|
|
341
|
+
audioTracks.pushMap(audioTrack);
|
|
474
342
|
}
|
|
475
343
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
344
|
+
promise.resolve(audioTracks);
|
|
345
|
+
} else {
|
|
346
|
+
promise.reject("RNJW Error", "Player is null");
|
|
347
|
+
}
|
|
348
|
+
});
|
|
480
349
|
}
|
|
481
350
|
|
|
482
351
|
@ReactMethod
|
|
483
352
|
public void getCurrentAudioTrack(final int reactTag, final Promise promise) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
} else {
|
|
493
|
-
promise.reject("RNJW Error", "Player is null");
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
} catch (IllegalViewOperationException e) {
|
|
498
|
-
promise.reject("RNJW Error", e);
|
|
499
|
-
}
|
|
353
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
354
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
355
|
+
if (playerView != null && playerView.mPlayer != null) {
|
|
356
|
+
promise.resolve(playerView.mPlayer.getCurrentAudioTrack());
|
|
357
|
+
} else {
|
|
358
|
+
promise.reject("RNJW Error", "Player is null");
|
|
359
|
+
}
|
|
360
|
+
});
|
|
500
361
|
}
|
|
501
362
|
|
|
502
363
|
@ReactMethod
|
|
503
364
|
public void setCurrentAudioTrack(final int reactTag, final int index) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
if (playerView != null && playerView.mPlayer != null) {
|
|
511
|
-
playerView.mPlayer.setCurrentAudioTrack(index);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
} catch (IllegalViewOperationException e) {
|
|
516
|
-
throw e;
|
|
517
|
-
}
|
|
365
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
366
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
367
|
+
if (playerView != null && playerView.mPlayer != null) {
|
|
368
|
+
playerView.mPlayer.setCurrentAudioTrack(index);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
518
371
|
}
|
|
519
372
|
|
|
520
373
|
@ReactMethod
|
|
521
374
|
public void setCurrentCaptions(final int reactTag, final int index) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (playerView != null && playerView.mPlayer != null) {
|
|
529
|
-
playerView.mPlayer.setCurrentCaptions(index);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
} catch (IllegalViewOperationException e) {
|
|
534
|
-
throw e;
|
|
535
|
-
}
|
|
375
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
376
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
377
|
+
if (playerView != null && playerView.mPlayer != null) {
|
|
378
|
+
playerView.mPlayer.setCurrentCaptions(index);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
536
381
|
}
|
|
537
382
|
|
|
538
|
-
|
|
539
383
|
@ReactMethod
|
|
540
384
|
public void getCurrentCaptions(final int reactTag, final Promise promise) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
uiManager.addUIBlock(new UIBlock() {
|
|
544
|
-
public void execute (NativeViewHierarchyManager nvhm) {
|
|
545
|
-
RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag);
|
|
546
|
-
|
|
385
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
386
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
547
387
|
if (playerView != null && playerView.mPlayer != null) {
|
|
548
|
-
|
|
388
|
+
promise.resolve(playerView.mPlayer.getCurrentCaptions());
|
|
549
389
|
} else {
|
|
550
|
-
|
|
390
|
+
promise.reject("RNJW Error", "Player is null");
|
|
551
391
|
}
|
|
552
|
-
}
|
|
553
392
|
});
|
|
554
|
-
} catch (IllegalViewOperationException e) {
|
|
555
|
-
throw e;
|
|
556
|
-
}
|
|
557
393
|
}
|
|
558
394
|
|
|
395
|
+
@ReactMethod
|
|
396
|
+
public void resolveNextPlaylistItem(final int reactTag, final ReadableMap playlistItem) {
|
|
397
|
+
new Handler(Looper.getMainLooper()).post(() -> {
|
|
398
|
+
RNJWPlayerView playerView = getPlayerView(reactTag);
|
|
399
|
+
if (playerView != null && playerView.mPlayerView != null) {
|
|
400
|
+
playerView.resolveNextPlaylistItem(playlistItem);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
559
404
|
|
|
560
405
|
private int stateToInt(PlayerState playerState) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
406
|
+
switch (playerState) {
|
|
407
|
+
case IDLE:
|
|
408
|
+
return 0;
|
|
409
|
+
case BUFFERING:
|
|
410
|
+
return 1;
|
|
411
|
+
case PLAYING:
|
|
412
|
+
return 2;
|
|
413
|
+
case PAUSED:
|
|
414
|
+
return 3;
|
|
415
|
+
case COMPLETE:
|
|
416
|
+
return 4;
|
|
417
|
+
case ERROR:
|
|
418
|
+
return 5;
|
|
419
|
+
default:
|
|
420
|
+
return -1;
|
|
421
|
+
}
|
|
577
422
|
}
|
|
578
423
|
}
|