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