@jwplayer/jwplayer-react-native 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +2 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/ISSUE_TEMPLATE/question.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/LICENSE +21 -0
- package/README.md +425 -0
- package/RNJWPlayer.podspec +44 -0
- package/android/.gradle/8.1.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.1.1/gc.properties +0 -0
- package/android/.gradle/8.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +12 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +54 -0
- package/android/build.gradle +110 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/ArrayUtil.java +129 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/CastOptionsProvider.java +55 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/MapUtil.java +136 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayer.java +76 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerAds.java +239 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerModule.java +526 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerPackage.java +30 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java +1499 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerViewManager.java +171 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/Util.java +219 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/WidevineCallback.java +62 -0
- package/badges/license.svg +1 -0
- package/badges/version.svg +1 -0
- package/docs/legacy_readme.md +634 -0
- package/docs/props.md +43 -0
- package/docs/types.md +254 -0
- package/index.d.ts +564 -0
- package/index.js +699 -0
- package/ios/RNJWPlayer/RCTConvert+RNJWPlayer.swift +119 -0
- package/ios/RNJWPlayer/RNJWPlayer-Bridging-Header.h +5 -0
- package/ios/RNJWPlayer/RNJWPlayerAds.swift +260 -0
- package/ios/RNJWPlayer/RNJWPlayerModels.swift +149 -0
- package/ios/RNJWPlayer/RNJWPlayerView.swift +1837 -0
- package/ios/RNJWPlayer/RNJWPlayerViewController.swift +616 -0
- package/ios/RNJWPlayer/RNJWPlayerViewManager.m +132 -0
- package/ios/RNJWPlayer/RNJWPlayerViewManager.swift +500 -0
- package/ios/RNJWPlayer.xcodeproj/project.pbxproj +323 -0
- package/package.json +45 -0
package/index.js
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
requireNativeComponent,
|
|
4
|
+
NativeModules,
|
|
5
|
+
Platform,
|
|
6
|
+
findNodeHandle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import _ from 'lodash';
|
|
10
|
+
|
|
11
|
+
const RNJWPlayerManager =
|
|
12
|
+
Platform.OS === 'ios'
|
|
13
|
+
? NativeModules.RNJWPlayerViewManager
|
|
14
|
+
: NativeModules.RNJWPlayerModule;
|
|
15
|
+
|
|
16
|
+
let playerId = 0;
|
|
17
|
+
const RCT_RNJWPLAYER_REF = 'RNJWPlayerKey';
|
|
18
|
+
|
|
19
|
+
const RNJWPlayer = requireNativeComponent('RNJWPlayerView');
|
|
20
|
+
|
|
21
|
+
const JWPlayerStateIOS = {
|
|
22
|
+
JWPlayerStateUnknown: 0,
|
|
23
|
+
JWPlayerStateIdle: 1,
|
|
24
|
+
JWPlayerStateBuffering: 2,
|
|
25
|
+
JWPlayerStatePlaying: 3,
|
|
26
|
+
JWPlayerStatePaused: 4,
|
|
27
|
+
JWPlayerStateComplete: 5,
|
|
28
|
+
JWPlayerStateError: 6,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const JWPlayerStateAndroid = {
|
|
32
|
+
JWPlayerStateIdle: 0,
|
|
33
|
+
JWPlayerStateBuffering: 1,
|
|
34
|
+
JWPlayerStatePlaying: 2,
|
|
35
|
+
JWPlayerStatePaused: 3,
|
|
36
|
+
JWPlayerStateComplete: 4,
|
|
37
|
+
JWPlayerStateError: null,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const JWPlayerAdEvents = {
|
|
41
|
+
/// This event is reported when the ad break has come to an end.
|
|
42
|
+
JWAdEventTypeAdBreakEnd: 0,
|
|
43
|
+
/// This event is reported when the ad break has begun.
|
|
44
|
+
JWAdEventTypeAdBreakStart: 1,
|
|
45
|
+
/// This event is reported when the user taps the ad.
|
|
46
|
+
JWAdEventTypeClicked: 2,
|
|
47
|
+
/// This event is reported when the ad is done playing.
|
|
48
|
+
JWAdEventTypeComplete: 3,
|
|
49
|
+
/// This event is used to report the ad impression, supplying additional detailed information about the ad.
|
|
50
|
+
JWAdEventTypeImpression: 4,
|
|
51
|
+
/// This event reports meta data information associated with the ad.
|
|
52
|
+
JWAdEventTypeMeta: 5,
|
|
53
|
+
/// The event is reported when the ad pauses.
|
|
54
|
+
JWAdEventTypePause: 6,
|
|
55
|
+
/// This event is reported when the ad begins playing, even in the middle of the stream after it was paused.
|
|
56
|
+
JWAdEventTypePlay: 7,
|
|
57
|
+
/// The event reports data about the ad request, when the ad is about to be loaded.
|
|
58
|
+
JWAdEventTypeRequest: 8,
|
|
59
|
+
/// This event reports the schedule of ads across the currently playing content.
|
|
60
|
+
JWAdEventTypeSchedule: 9,
|
|
61
|
+
/// This event is reported when the user skips the ad.
|
|
62
|
+
JWAdEventTypeSkipped: 10,
|
|
63
|
+
/// This event is reported when the ad begins.
|
|
64
|
+
JWAdEventTypeStarted: 11,
|
|
65
|
+
/// This event relays information about ad companions.
|
|
66
|
+
JWAdEventTypeCompanion: 12,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const JWPlayerState =
|
|
70
|
+
Platform.OS === 'ios' ? JWPlayerStateIOS : JWPlayerStateAndroid;
|
|
71
|
+
|
|
72
|
+
export const JWPlayerAdClients = {
|
|
73
|
+
JWAdClientJWPlayer: 0,
|
|
74
|
+
JWAdClientGoogleIMA: 1,
|
|
75
|
+
JWAdClientGoogleIMADAI: 2,
|
|
76
|
+
JWAdClientUnknown: 3,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Common PropTypes for imaSettings and adRules
|
|
80
|
+
const imaSettingsPropTypes = PropTypes.shape({
|
|
81
|
+
locale: PropTypes.string,
|
|
82
|
+
ppid: PropTypes.string,
|
|
83
|
+
maxRedirects: PropTypes.number,
|
|
84
|
+
sessionID: PropTypes.string,
|
|
85
|
+
debugMode: PropTypes.bool,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const adRulesPropTypes = PropTypes.shape({
|
|
89
|
+
startOn: PropTypes.number,
|
|
90
|
+
frequency: PropTypes.number,
|
|
91
|
+
timeBetweenAds: PropTypes.number,
|
|
92
|
+
startOnSeek: PropTypes.oneOf(['none', 'pre']),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const adSettingsPropTypes = PropTypes.shape({
|
|
96
|
+
allowsBackgroundPlayback: PropTypes.bool,
|
|
97
|
+
// Include other ad settings properties here
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const adSchedulePropTypes = PropTypes.arrayOf(
|
|
101
|
+
PropTypes.shape({
|
|
102
|
+
tag: PropTypes.string,
|
|
103
|
+
offset: PropTypes.string,
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Define PropTypes for each ad client type
|
|
108
|
+
const vastAdvertisingPropTypes = {
|
|
109
|
+
adClient: PropTypes.oneOf(['vast']),
|
|
110
|
+
adSchedule: adSchedulePropTypes,
|
|
111
|
+
adVmap: PropTypes.string,
|
|
112
|
+
tag: PropTypes.string,
|
|
113
|
+
openBrowserOnAdClick: PropTypes.bool,
|
|
114
|
+
adRules: adRulesPropTypes,
|
|
115
|
+
adSettings: adSettingsPropTypes,
|
|
116
|
+
// Add other VAST-specific properties here
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const imaAdvertisingPropTypes = {
|
|
120
|
+
adClient: PropTypes.oneOf(['ima']),
|
|
121
|
+
adSchedule: adSchedulePropTypes,
|
|
122
|
+
adVmap: PropTypes.string,
|
|
123
|
+
tag: PropTypes.string,
|
|
124
|
+
imaSettings: imaSettingsPropTypes,
|
|
125
|
+
adRules: adRulesPropTypes,
|
|
126
|
+
// companionAdSlots: PropTypes.arrayOf(
|
|
127
|
+
// PropTypes.shape({
|
|
128
|
+
// viewId: PropTypes.string,
|
|
129
|
+
// size: PropTypes.shape({
|
|
130
|
+
// width: PropTypes.number,
|
|
131
|
+
// height: PropTypes.number,
|
|
132
|
+
// }),
|
|
133
|
+
// })
|
|
134
|
+
// ),
|
|
135
|
+
// friendlyObstructions: PropTypes.arrayOf(
|
|
136
|
+
// PropTypes.shape({
|
|
137
|
+
// viewId: PropTypes.string,
|
|
138
|
+
// purpose: PropTypes.oneOf(['mediaControls', 'closeAd', 'notVisible', 'other']),
|
|
139
|
+
// reason: PropTypes.string,
|
|
140
|
+
// })
|
|
141
|
+
// ),
|
|
142
|
+
// Add other IMA-specific properties here
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const imaDaiAdvertisingPropTypes = {
|
|
146
|
+
adClient: PropTypes.oneOf(['ima_dai']),
|
|
147
|
+
imaSettings: imaSettingsPropTypes,
|
|
148
|
+
googleDAIStream: PropTypes.shape({
|
|
149
|
+
videoID: PropTypes.string,
|
|
150
|
+
cmsID: PropTypes.string,
|
|
151
|
+
assetKey: PropTypes.string,
|
|
152
|
+
apiKey: PropTypes.string,
|
|
153
|
+
adTagParameters: PropTypes.object,
|
|
154
|
+
}),
|
|
155
|
+
// friendlyObstructions: PropTypes.arrayOf(
|
|
156
|
+
// PropTypes.shape({
|
|
157
|
+
// viewId: PropTypes.string,
|
|
158
|
+
// purpose: PropTypes.oneOf(['mediaControls', 'closeAd', 'notVisible', 'other']),
|
|
159
|
+
// reason: PropTypes.string,
|
|
160
|
+
// })
|
|
161
|
+
// ),
|
|
162
|
+
// Add other IMA DAI-specific properties here
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const advertisingPropTypes = PropTypes.oneOfType([
|
|
166
|
+
PropTypes.shape(vastAdvertisingPropTypes),
|
|
167
|
+
PropTypes.shape(imaAdvertisingPropTypes),
|
|
168
|
+
PropTypes.shape(imaDaiAdvertisingPropTypes),
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
export default class JWPlayer extends Component {
|
|
172
|
+
// [TODO] -- Match the JwConfig type from index.d.ts as oneOfType
|
|
173
|
+
static propTypes = {
|
|
174
|
+
config: PropTypes.shape({
|
|
175
|
+
license: PropTypes.string.isRequired,
|
|
176
|
+
forceLegacyConfig: PropTypes.bool,
|
|
177
|
+
backgroundAudioEnabled: PropTypes.bool,
|
|
178
|
+
category: PropTypes.oneOf([
|
|
179
|
+
'Ambient',
|
|
180
|
+
'SoloAmbient',
|
|
181
|
+
'Playback',
|
|
182
|
+
'Record',
|
|
183
|
+
'PlayAndRecord',
|
|
184
|
+
'MultiRoute',
|
|
185
|
+
]),
|
|
186
|
+
categoryOptions: PropTypes.arrayOf(
|
|
187
|
+
PropTypes.oneOf([
|
|
188
|
+
'MixWithOthers',
|
|
189
|
+
'DuckOthers',
|
|
190
|
+
'AllowBluetooth',
|
|
191
|
+
'DefaultToSpeaker',
|
|
192
|
+
'InterruptSpokenAudioAndMix',
|
|
193
|
+
'AllowBluetoothA2DP',
|
|
194
|
+
'AllowAirPlay',
|
|
195
|
+
'OverrideMutedMicrophone',
|
|
196
|
+
])
|
|
197
|
+
),
|
|
198
|
+
mode: PropTypes.oneOf([
|
|
199
|
+
'Default',
|
|
200
|
+
'VoiceChat',
|
|
201
|
+
'VideoChat',
|
|
202
|
+
'GameChat',
|
|
203
|
+
'VideoRecording',
|
|
204
|
+
'Measurement',
|
|
205
|
+
'MoviePlayback',
|
|
206
|
+
'SpokenAudio',
|
|
207
|
+
'VoicePrompt',
|
|
208
|
+
]),
|
|
209
|
+
pipEnabled: PropTypes.bool,
|
|
210
|
+
viewOnly: PropTypes.bool,
|
|
211
|
+
autostart: PropTypes.bool,
|
|
212
|
+
controls: PropTypes.bool,
|
|
213
|
+
repeat: PropTypes.bool,
|
|
214
|
+
preload: PropTypes.oneOf(['auto', 'none']),
|
|
215
|
+
playlist: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(
|
|
216
|
+
PropTypes.shape({
|
|
217
|
+
file: PropTypes.string,
|
|
218
|
+
sources: PropTypes.arrayOf(
|
|
219
|
+
PropTypes.shape({
|
|
220
|
+
file: PropTypes.string,
|
|
221
|
+
label: PropTypes.string,
|
|
222
|
+
default: PropTypes.bool,
|
|
223
|
+
})
|
|
224
|
+
),
|
|
225
|
+
image: PropTypes.string,
|
|
226
|
+
title: PropTypes.string,
|
|
227
|
+
desc: PropTypes.string,
|
|
228
|
+
mediaId: PropTypes.string,
|
|
229
|
+
autostart: PropTypes.bool,
|
|
230
|
+
recommendations: PropTypes.string,
|
|
231
|
+
tracks: PropTypes.arrayOf(
|
|
232
|
+
PropTypes.shape({
|
|
233
|
+
file: PropTypes.string,
|
|
234
|
+
label: PropTypes.string,
|
|
235
|
+
})
|
|
236
|
+
),
|
|
237
|
+
adSchedule: PropTypes.arrayOf(
|
|
238
|
+
PropTypes.shape({
|
|
239
|
+
tag: PropTypes.string,
|
|
240
|
+
offset: PropTypes.string,
|
|
241
|
+
})
|
|
242
|
+
),
|
|
243
|
+
adVmap: PropTypes.string,
|
|
244
|
+
startTime: PropTypes.number,
|
|
245
|
+
})
|
|
246
|
+
)]),
|
|
247
|
+
advertising: advertisingPropTypes,
|
|
248
|
+
|
|
249
|
+
// controller only
|
|
250
|
+
interfaceBehavior: PropTypes.oneOf([
|
|
251
|
+
'normal',
|
|
252
|
+
'hidden',
|
|
253
|
+
'onscreen',
|
|
254
|
+
]),
|
|
255
|
+
styling: PropTypes.shape({
|
|
256
|
+
colors: PropTypes.shape({
|
|
257
|
+
buttons: PropTypes.string,
|
|
258
|
+
backgroundColor: PropTypes.string,
|
|
259
|
+
fontColor: PropTypes.string,
|
|
260
|
+
timeslider: PropTypes.shape({
|
|
261
|
+
thumb: PropTypes.string,
|
|
262
|
+
rail: PropTypes.string,
|
|
263
|
+
slider: PropTypes.string,
|
|
264
|
+
}),
|
|
265
|
+
font: PropTypes.shape({
|
|
266
|
+
name: PropTypes.string,
|
|
267
|
+
size: PropTypes.number,
|
|
268
|
+
}),
|
|
269
|
+
captionsStyle: PropTypes.shape({
|
|
270
|
+
font: PropTypes.shape({
|
|
271
|
+
name: PropTypes.string,
|
|
272
|
+
size: PropTypes.number,
|
|
273
|
+
}),
|
|
274
|
+
backgroundColor: PropTypes.string,
|
|
275
|
+
fontColor: PropTypes.string,
|
|
276
|
+
highlightColor: PropTypes.string,
|
|
277
|
+
edgeStyle: PropTypes.oneOf([
|
|
278
|
+
'none',
|
|
279
|
+
'dropshadow',
|
|
280
|
+
'raised',
|
|
281
|
+
'depressed',
|
|
282
|
+
'uniform',
|
|
283
|
+
]),
|
|
284
|
+
}),
|
|
285
|
+
menuStyle: PropTypes.shape({
|
|
286
|
+
font: PropTypes.shape({
|
|
287
|
+
name: PropTypes.string,
|
|
288
|
+
size: PropTypes.number,
|
|
289
|
+
}),
|
|
290
|
+
backgroundColor: PropTypes.string,
|
|
291
|
+
fontColor: PropTypes.string,
|
|
292
|
+
}),
|
|
293
|
+
}),
|
|
294
|
+
showTitle: PropTypes.bool,
|
|
295
|
+
showDesc: PropTypes.bool,
|
|
296
|
+
}),
|
|
297
|
+
nextUpStyle: PropTypes.shape({
|
|
298
|
+
offsetSeconds: PropTypes.number,
|
|
299
|
+
offsetPercentage: PropTypes.number,
|
|
300
|
+
}),
|
|
301
|
+
offlineMessage: PropTypes.string,
|
|
302
|
+
offlineImage: PropTypes.string,
|
|
303
|
+
forceFullScreenOnLandscape: PropTypes.bool,
|
|
304
|
+
forceLandscapeOnFullScreen: PropTypes.bool,
|
|
305
|
+
enableLockScreenControls: PropTypes.bool,
|
|
306
|
+
stretching: PropTypes.oneOf([
|
|
307
|
+
'uniform',
|
|
308
|
+
'exactFit',
|
|
309
|
+
'fill',
|
|
310
|
+
'none',
|
|
311
|
+
]),
|
|
312
|
+
processSpcUrl: PropTypes.string,
|
|
313
|
+
fairplayCertUrl: PropTypes.string,
|
|
314
|
+
contentUUID: PropTypes.string,
|
|
315
|
+
}),
|
|
316
|
+
onPlayerReady: PropTypes.func,
|
|
317
|
+
onPlaylist: PropTypes.func,
|
|
318
|
+
changePlaylist: PropTypes.func,
|
|
319
|
+
play: PropTypes.func,
|
|
320
|
+
pause: PropTypes.func,
|
|
321
|
+
setVolume: PropTypes.func,
|
|
322
|
+
toggleSpeed: PropTypes.func,
|
|
323
|
+
setSpeed: PropTypes.func,
|
|
324
|
+
setCurrentQuality: PropTypes.func,
|
|
325
|
+
currentQuality: PropTypes.func,
|
|
326
|
+
getQualityLevels: PropTypes.func,
|
|
327
|
+
setPlaylistIndex: PropTypes.func,
|
|
328
|
+
setControls: PropTypes.func,
|
|
329
|
+
setVisibility: PropTypes.func,
|
|
330
|
+
setLockScreenControls: PropTypes.func,
|
|
331
|
+
setFullscreen: PropTypes.func,
|
|
332
|
+
setUpCastController: PropTypes.func,
|
|
333
|
+
presentCastDialog: PropTypes.func,
|
|
334
|
+
connectedDevice: PropTypes.func,
|
|
335
|
+
availableDevices: PropTypes.func,
|
|
336
|
+
castState: PropTypes.func,
|
|
337
|
+
seekTo: PropTypes.func,
|
|
338
|
+
loadPlaylist: PropTypes.func,
|
|
339
|
+
onBeforePlay: PropTypes.func,
|
|
340
|
+
onBeforeComplete: PropTypes.func,
|
|
341
|
+
onPlay: PropTypes.func,
|
|
342
|
+
onPause: PropTypes.func,
|
|
343
|
+
onSetupPlayerError: PropTypes.func,
|
|
344
|
+
onPlayerError: PropTypes.func,
|
|
345
|
+
onPlayerWarning: PropTypes.func,
|
|
346
|
+
onPlayerAdError: PropTypes.func,
|
|
347
|
+
onPlayerAdWarning: PropTypes.func,
|
|
348
|
+
onAdEvent: PropTypes.func,
|
|
349
|
+
onAdTime: PropTypes.func,
|
|
350
|
+
onBuffer: PropTypes.func,
|
|
351
|
+
onTime: PropTypes.func,
|
|
352
|
+
onComplete: PropTypes.func,
|
|
353
|
+
onFullScreenRequested: PropTypes.func,
|
|
354
|
+
onFullScreen: PropTypes.func,
|
|
355
|
+
onFullScreenExitRequested: PropTypes.func,
|
|
356
|
+
onFullScreenExit: PropTypes.func,
|
|
357
|
+
onSeek: PropTypes.func,
|
|
358
|
+
onSeeked: PropTypes.func,
|
|
359
|
+
onRateChanged: PropTypes.func,
|
|
360
|
+
onPlaylistItem: PropTypes.func,
|
|
361
|
+
onControlBarVisible: PropTypes.func,
|
|
362
|
+
onPlaylistComplete: PropTypes.func,
|
|
363
|
+
getAudioTracks: PropTypes.func,
|
|
364
|
+
getCurrentAudioTrack: PropTypes.func,
|
|
365
|
+
setCurrentAudioTrack: PropTypes.func,
|
|
366
|
+
setCurrentCaptions: PropTypes.func,
|
|
367
|
+
onAudioTracks: PropTypes.func,
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
constructor(props) {
|
|
371
|
+
super(props);
|
|
372
|
+
|
|
373
|
+
this._playerId = playerId++;
|
|
374
|
+
this.ref_key = `${RCT_RNJWPLAYER_REF}-${this._playerId}`;
|
|
375
|
+
|
|
376
|
+
this.quite();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
380
|
+
var { shouldComponentUpdate } = this.props;
|
|
381
|
+
if (shouldComponentUpdate) {
|
|
382
|
+
return shouldComponentUpdate(nextProps, nextState);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var { config, controls } = nextProps;
|
|
386
|
+
var thisConfig = this.props.config || {};
|
|
387
|
+
|
|
388
|
+
var result = !_.isEqualWith(
|
|
389
|
+
config,
|
|
390
|
+
thisConfig,
|
|
391
|
+
(value1, value2, key) => {
|
|
392
|
+
return key === 'startTime' ? true : undefined;
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
return result || controls !== this.props.controls;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
componentWillUnmount() {
|
|
400
|
+
this.pause();
|
|
401
|
+
this.stop();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
quite() {
|
|
405
|
+
if (RNJWPlayerManager && Platform.OS === 'ios')
|
|
406
|
+
RNJWPlayerManager.quite();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
pause() {
|
|
410
|
+
if (RNJWPlayerManager)
|
|
411
|
+
RNJWPlayerManager.pause(this.getRNJWPlayerBridgeHandle());
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
changePlaylist(fileUrl) {
|
|
415
|
+
if (RNJWPlayerManager)
|
|
416
|
+
RNJWPlayerManager.changePlaylist(
|
|
417
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
418
|
+
fileUrl
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
play() {
|
|
423
|
+
if (RNJWPlayerManager)
|
|
424
|
+
RNJWPlayerManager.play(this.getRNJWPlayerBridgeHandle());
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
stop() {
|
|
428
|
+
if (RNJWPlayerManager)
|
|
429
|
+
RNJWPlayerManager.stop(this.getRNJWPlayerBridgeHandle());
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
toggleSpeed() {
|
|
433
|
+
if (RNJWPlayerManager)
|
|
434
|
+
RNJWPlayerManager.toggleSpeed(this.getRNJWPlayerBridgeHandle());
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
setSpeed(speed) {
|
|
438
|
+
if (RNJWPlayerManager)
|
|
439
|
+
RNJWPlayerManager.setSpeed(this.getRNJWPlayerBridgeHandle(), speed);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
setCurrentQuality(index) {
|
|
443
|
+
if (RNJWPlayerManager && Platform.OS === "android")
|
|
444
|
+
RNJWPlayerManager.setCurrentQuality(
|
|
445
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
446
|
+
index
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
currentQuality() {
|
|
451
|
+
if (RNJWPlayerManager && Platform.OS === "android")
|
|
452
|
+
return RNJWPlayerManager.getCurrentQuality(
|
|
453
|
+
this.getRNJWPlayerBridgeHandle()
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async getQualityLevels() {
|
|
458
|
+
if (RNJWPlayerManager && Platform.OS === "android") {
|
|
459
|
+
try {
|
|
460
|
+
var qualityLevels = await RNJWPlayerManager.getQualityLevels(
|
|
461
|
+
this.getRNJWPlayerBridgeHandle()
|
|
462
|
+
);
|
|
463
|
+
return qualityLevels;
|
|
464
|
+
} catch (e) {
|
|
465
|
+
console.error(e);
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
setPlaylistIndex(index) {
|
|
472
|
+
if (RNJWPlayerManager)
|
|
473
|
+
RNJWPlayerManager.setPlaylistIndex(
|
|
474
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
475
|
+
index
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
setControls(show) {
|
|
480
|
+
if (RNJWPlayerManager)
|
|
481
|
+
RNJWPlayerManager.setControls(
|
|
482
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
483
|
+
show
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
setVisibility(visibility, controls) {
|
|
488
|
+
if (RNJWPlayerManager && Platform.OS === 'ios')
|
|
489
|
+
RNJWPlayerManager.setVisibility(
|
|
490
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
491
|
+
visibility,
|
|
492
|
+
controls
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
setLockScreenControls(show) {
|
|
497
|
+
if (RNJWPlayerManager && Platform.OS === 'ios')
|
|
498
|
+
RNJWPlayerManager.setLockScreenControls(
|
|
499
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
500
|
+
show
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
seekTo(time) {
|
|
505
|
+
if (RNJWPlayerManager)
|
|
506
|
+
RNJWPlayerManager.seekTo(this.getRNJWPlayerBridgeHandle(), time);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
loadPlaylist(playlistItems) {
|
|
510
|
+
if (RNJWPlayerManager)
|
|
511
|
+
RNJWPlayerManager.loadPlaylist(this.getRNJWPlayerBridgeHandle(), playlistItems);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
setFullscreen(fullscreen) {
|
|
515
|
+
if (RNJWPlayerManager)
|
|
516
|
+
RNJWPlayerManager.setFullscreen(
|
|
517
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
518
|
+
fullscreen
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
setVolume(value) {
|
|
523
|
+
if (RNJWPlayerManager) {
|
|
524
|
+
RNJWPlayerManager.setVolume(
|
|
525
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
526
|
+
value
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async time() {
|
|
532
|
+
if (RNJWPlayerManager) {
|
|
533
|
+
try {
|
|
534
|
+
var time = await RNJWPlayerManager.time(
|
|
535
|
+
this.getRNJWPlayerBridgeHandle()
|
|
536
|
+
);
|
|
537
|
+
return time;
|
|
538
|
+
} catch (e) {
|
|
539
|
+
console.error(e);
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async position() {
|
|
546
|
+
if (RNJWPlayerManager) {
|
|
547
|
+
try {
|
|
548
|
+
var position = await RNJWPlayerManager.position(
|
|
549
|
+
this.getRNJWPlayerBridgeHandle()
|
|
550
|
+
);
|
|
551
|
+
return position;
|
|
552
|
+
} catch (e) {
|
|
553
|
+
console.error(e);
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
togglePIP() {
|
|
560
|
+
if (RNJWPlayerManager)
|
|
561
|
+
RNJWPlayerManager.togglePIP(this.getRNJWPlayerBridgeHandle());
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
setUpCastController() {
|
|
565
|
+
if (RNJWPlayerManager && Platform.OS === 'ios')
|
|
566
|
+
RNJWPlayerManager.setUpCastController(
|
|
567
|
+
this.getRNJWPlayerBridgeHandle()
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
presentCastDialog() {
|
|
572
|
+
if (RNJWPlayerManager && Platform.OS === 'ios')
|
|
573
|
+
RNJWPlayerManager.presentCastDialog(
|
|
574
|
+
this.getRNJWPlayerBridgeHandle()
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
async connectedDevice() {
|
|
579
|
+
if (RNJWPlayerManager && Platform.OS === 'ios') {
|
|
580
|
+
try {
|
|
581
|
+
var connectedDevice = await RNJWPlayerManager.connectedDevice(
|
|
582
|
+
this.getRNJWPlayerBridgeHandle()
|
|
583
|
+
);
|
|
584
|
+
return connectedDevice;
|
|
585
|
+
} catch (e) {
|
|
586
|
+
console.error(e);
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
async availableDevices() {
|
|
593
|
+
if (RNJWPlayerManager && Platform.OS === 'ios') {
|
|
594
|
+
try {
|
|
595
|
+
var availableDevices = await RNJWPlayerManager.availableDevices(
|
|
596
|
+
this.getRNJWPlayerBridgeHandle()
|
|
597
|
+
);
|
|
598
|
+
return availableDevices;
|
|
599
|
+
} catch (e) {
|
|
600
|
+
console.error(e);
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
async castState() {
|
|
607
|
+
if (RNJWPlayerManager && Platform.OS === 'ios') {
|
|
608
|
+
try {
|
|
609
|
+
var castState = await RNJWPlayerManager.castState(
|
|
610
|
+
this.getRNJWPlayerBridgeHandle()
|
|
611
|
+
);
|
|
612
|
+
return castState;
|
|
613
|
+
} catch (e) {
|
|
614
|
+
console.error(e);
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
async playerState() {
|
|
621
|
+
if (RNJWPlayerManager) {
|
|
622
|
+
try {
|
|
623
|
+
var state = await RNJWPlayerManager.state(
|
|
624
|
+
this.getRNJWPlayerBridgeHandle()
|
|
625
|
+
);
|
|
626
|
+
return state;
|
|
627
|
+
} catch (e) {
|
|
628
|
+
console.error(e);
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
async getAudioTracks() {
|
|
635
|
+
if (RNJWPlayerManager) {
|
|
636
|
+
try {
|
|
637
|
+
var audioTracks = await RNJWPlayerManager.getAudioTracks(
|
|
638
|
+
this.getRNJWPlayerBridgeHandle()
|
|
639
|
+
);
|
|
640
|
+
// iOS sends autoSelect as 0 or 1 instead of a boolean
|
|
641
|
+
// couldn't figure out how to send autoSelect as a boolean from Objective C
|
|
642
|
+
return audioTracks.map((audioTrack) => {
|
|
643
|
+
audioTrack.autoSelect = !!audioTrack.autoSelect;
|
|
644
|
+
return audioTrack;
|
|
645
|
+
});
|
|
646
|
+
} catch (e) {
|
|
647
|
+
console.error(e);
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
async getCurrentAudioTrack() {
|
|
654
|
+
if (RNJWPlayerManager) {
|
|
655
|
+
try {
|
|
656
|
+
var currentAudioTrack =
|
|
657
|
+
await RNJWPlayerManager.getCurrentAudioTrack(
|
|
658
|
+
this.getRNJWPlayerBridgeHandle()
|
|
659
|
+
);
|
|
660
|
+
return currentAudioTrack;
|
|
661
|
+
} catch (e) {
|
|
662
|
+
console.error(e);
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
setCurrentAudioTrack(index) {
|
|
669
|
+
if (RNJWPlayerManager) {
|
|
670
|
+
RNJWPlayerManager.setCurrentAudioTrack(
|
|
671
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
672
|
+
index
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
setCurrentCaptions(index) {
|
|
678
|
+
if (RNJWPlayerManager) {
|
|
679
|
+
RNJWPlayerManager.setCurrentCaptions(
|
|
680
|
+
this.getRNJWPlayerBridgeHandle(),
|
|
681
|
+
index
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
getRNJWPlayerBridgeHandle() {
|
|
687
|
+
return findNodeHandle(this[this.ref_key]);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
render() {
|
|
691
|
+
return (
|
|
692
|
+
<RNJWPlayer
|
|
693
|
+
ref={(player) => (this[this.ref_key] = player)}
|
|
694
|
+
key={this.ref_key}
|
|
695
|
+
{...this.props}
|
|
696
|
+
/>
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
}
|