@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package com.jwplayer.rnjwplayer;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
import android.content.res.Configuration;
|
|
6
|
+
import android.view.KeyEvent;
|
|
7
|
+
|
|
8
|
+
import com.jwplayer.pub.view.JWPlayerView;
|
|
9
|
+
|
|
10
|
+
public class RNJWPlayer extends JWPlayerView {
|
|
11
|
+
public Boolean fullScreenOnLandscape = false;
|
|
12
|
+
public Boolean exitFullScreenOnPortrait = false;
|
|
13
|
+
|
|
14
|
+
public RNJWPlayer(Context var1) {
|
|
15
|
+
super(var1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
20
|
+
// Exit fullscreen or perform the action requested
|
|
21
|
+
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && this.getPlayer().getFullscreen()) {
|
|
22
|
+
if (event.getAction() == KeyEvent.ACTION_UP) {
|
|
23
|
+
this.getPlayer().setFullscreen(false,false);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return super.dispatchKeyEvent(event);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public void requestLayout() {
|
|
32
|
+
super.requestLayout();
|
|
33
|
+
|
|
34
|
+
// The spinner relies on a measure + layout pass happening after it calls requestLayout().
|
|
35
|
+
// Without this, the widget never actually changes the selection and doesn't call the
|
|
36
|
+
// appropriate listeners. Since we override onLayout in our ViewGroups, a layout pass never
|
|
37
|
+
// happens after a call to requestLayout, so we simulate one here.
|
|
38
|
+
post(measureAndLayout);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
private final Runnable measureAndLayout = new Runnable() {
|
|
43
|
+
@Override
|
|
44
|
+
public void run() {
|
|
45
|
+
measure(
|
|
46
|
+
MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
|
|
47
|
+
MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
|
|
48
|
+
layout(getLeft(), getTop(), getRight(), getBottom());
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
protected void onConfigurationChanged(Configuration newConfig) {
|
|
54
|
+
super.onConfigurationChanged(newConfig);
|
|
55
|
+
|
|
56
|
+
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
57
|
+
if (fullScreenOnLandscape) {
|
|
58
|
+
this.getPlayer().setFullscreen(true,true);
|
|
59
|
+
}
|
|
60
|
+
} else if (newConfig.orientation==Configuration.ORIENTATION_PORTRAIT) {
|
|
61
|
+
if (exitFullScreenOnPortrait) {
|
|
62
|
+
this.getPlayer().setFullscreen(false,false);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
69
|
+
if (keyCode == KeyEvent.KEYCODE_BACK && this.getPlayer().getFullscreen()) {
|
|
70
|
+
this.getPlayer().setFullscreen(false,false);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return super.onKeyDown(keyCode, event);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
package com.jwplayer.rnjwplayer;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
+
import com.google.ads.interactivemedia.v3.api.FriendlyObstruction;
|
|
6
|
+
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
|
|
7
|
+
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;
|
|
8
|
+
import com.jwplayer.pub.api.configuration.ads.AdRules;
|
|
9
|
+
import com.jwplayer.pub.api.configuration.ads.AdvertisingConfig;
|
|
10
|
+
import com.jwplayer.pub.api.configuration.ads.VastAdvertisingConfig;
|
|
11
|
+
import com.jwplayer.pub.api.configuration.ads.dai.ImaDaiAdvertisingConfig;
|
|
12
|
+
import com.jwplayer.pub.api.configuration.ads.ima.ImaAdvertisingConfig;
|
|
13
|
+
import com.jwplayer.pub.api.media.ads.AdBreak;
|
|
14
|
+
import com.jwplayer.pub.api.media.ads.dai.ImaDaiSettings;
|
|
15
|
+
|
|
16
|
+
import java.util.ArrayList;
|
|
17
|
+
import java.util.HashMap;
|
|
18
|
+
import java.util.List;
|
|
19
|
+
import java.util.Map;
|
|
20
|
+
import java.util.Objects;
|
|
21
|
+
|
|
22
|
+
public class RNJWPlayerAds {
|
|
23
|
+
|
|
24
|
+
// Get advertising config based on the ad client type
|
|
25
|
+
public static AdvertisingConfig getAdvertisingConfig(ReadableMap ads) {
|
|
26
|
+
if (ads == null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
String adClientType = ads.getString("adClient");
|
|
31
|
+
switch (adClientType) {
|
|
32
|
+
case "ima":
|
|
33
|
+
try {
|
|
34
|
+
return configureImaAdvertising(ads);
|
|
35
|
+
} catch (Exception e) {
|
|
36
|
+
throw new RuntimeException(e);
|
|
37
|
+
}
|
|
38
|
+
case "ima_dai":
|
|
39
|
+
try {
|
|
40
|
+
return configureImaDaiAdvertising(ads);
|
|
41
|
+
} catch (Exception e) {
|
|
42
|
+
throw new RuntimeException(e);
|
|
43
|
+
}
|
|
44
|
+
default: // Defaulting to VAST
|
|
45
|
+
return configureVastAdvertising(ads);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Configure IMA Advertising
|
|
50
|
+
private static ImaAdvertisingConfig configureImaAdvertising(ReadableMap ads) throws Exception {
|
|
51
|
+
if (!BuildConfig.USE_IMA) {
|
|
52
|
+
throw new Exception("Error: Google ads services is not installed. Add RNJWPlayerUseGoogleIMA = true to your app/build.gradle ext {}");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ImaAdvertisingConfig.Builder builder = new ImaAdvertisingConfig.Builder();
|
|
56
|
+
|
|
57
|
+
List<AdBreak> adScheduleList = getAdSchedule(ads);
|
|
58
|
+
builder.schedule(adScheduleList);
|
|
59
|
+
|
|
60
|
+
if (ads.hasKey("imaSettings")) {
|
|
61
|
+
builder.imaSdkSettings(getImaSettings(Objects.requireNonNull(ads.getMap("imaSettings"))));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// companionSlots
|
|
65
|
+
|
|
66
|
+
return builder.build();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Configure IMA DAI Advertising
|
|
70
|
+
private static ImaDaiAdvertisingConfig configureImaDaiAdvertising(ReadableMap ads) throws Exception {
|
|
71
|
+
if (!BuildConfig.USE_IMA) {
|
|
72
|
+
throw new Exception("Error: Google ads services is not installed. Add RNJWPlayerUseGoogleIMA = true to your app/build.gradle ext {}");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ImaDaiAdvertisingConfig.Builder builder = new ImaDaiAdvertisingConfig.Builder();
|
|
76
|
+
|
|
77
|
+
if (ads.hasKey("imaSettings")) {
|
|
78
|
+
builder.imaSdkSettings(getImaSettings(Objects.requireNonNull(ads.getMap("imaSettings"))));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (ads.hasKey("imaDaiSettings")) {
|
|
82
|
+
builder.imaDaiSettings(getImaDaiSettings(Objects.requireNonNull(ads.getMap("imaDaiSettings"))));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return builder.build();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// You'll need to implement this method based on how you pass ImaDaiSettings from React Native
|
|
89
|
+
private static ImaDaiSettings getImaDaiSettings(ReadableMap imaDaiSettingsMap) {
|
|
90
|
+
String videoId = imaDaiSettingsMap.hasKey("videoId") ? imaDaiSettingsMap.getString("videoId") : null;
|
|
91
|
+
String cmsId = imaDaiSettingsMap.hasKey("cmsId") ? imaDaiSettingsMap.getString("cmsId") : null;
|
|
92
|
+
String assetKey = imaDaiSettingsMap.hasKey("assetKey") ? imaDaiSettingsMap.getString("assetKey") : null;
|
|
93
|
+
String apiKey = imaDaiSettingsMap.hasKey("apiKey") ? imaDaiSettingsMap.getString("apiKey") : null;
|
|
94
|
+
|
|
95
|
+
// Extracting adTagParameters from imaDaiSettingsMap if present
|
|
96
|
+
Map<String, String> adTagParameters = null;
|
|
97
|
+
if (imaDaiSettingsMap.hasKey("adTagParameters") && imaDaiSettingsMap.getMap("adTagParameters") != null) {
|
|
98
|
+
adTagParameters = new HashMap<>();
|
|
99
|
+
ReadableMap adTagParamsMap = imaDaiSettingsMap.getMap("adTagParameters");
|
|
100
|
+
for (Map.Entry<String, Object> entry : adTagParamsMap.toHashMap().entrySet()) {
|
|
101
|
+
if (entry.getValue() instanceof String) {
|
|
102
|
+
adTagParameters.put(entry.getKey(), (String) entry.getValue());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Handling streamType
|
|
108
|
+
ImaDaiSettings.StreamType streamType = ImaDaiSettings.StreamType.HLS; // Default to HLS
|
|
109
|
+
if (imaDaiSettingsMap.hasKey("streamType")) {
|
|
110
|
+
String streamTypeStr = imaDaiSettingsMap.getString("streamType");
|
|
111
|
+
if ("DASH".equalsIgnoreCase(streamTypeStr)) {
|
|
112
|
+
streamType = ImaDaiSettings.StreamType.DASH;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Create ImaDaiSettings based on the provided values
|
|
116
|
+
ImaDaiSettings imaDaiSettings = (assetKey != null) ?
|
|
117
|
+
new ImaDaiSettings(assetKey, streamType, apiKey) :
|
|
118
|
+
new ImaDaiSettings(videoId, cmsId, streamType, apiKey);
|
|
119
|
+
|
|
120
|
+
if (adTagParameters != null) {
|
|
121
|
+
imaDaiSettings.setAdTagParameters(adTagParameters);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return imaDaiSettings;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Configure VAST Advertising
|
|
128
|
+
private static VastAdvertisingConfig configureVastAdvertising(ReadableMap ads) {
|
|
129
|
+
VastAdvertisingConfig.Builder builder = new VastAdvertisingConfig.Builder();
|
|
130
|
+
|
|
131
|
+
List<AdBreak> adScheduleList = getAdSchedule(ads);
|
|
132
|
+
builder.schedule(adScheduleList);
|
|
133
|
+
|
|
134
|
+
if (ads.hasKey("skipText")) {
|
|
135
|
+
builder.skipText(ads.getString("skipText"));
|
|
136
|
+
}
|
|
137
|
+
if (ads.hasKey("skipMessage")) {
|
|
138
|
+
builder.skipMessage(ads.getString("skipMessage"));
|
|
139
|
+
}
|
|
140
|
+
// ... Add other VAST specific settings from ads ReadableMap
|
|
141
|
+
|
|
142
|
+
// Example: Handling VPAID controls
|
|
143
|
+
if (ads.hasKey("vpaidControls")) {
|
|
144
|
+
builder.vpaidControls(ads.getBoolean("vpaidControls"));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (ads.hasKey("adRules")) {
|
|
148
|
+
AdRules adRules = getAdRules(Objects.requireNonNull(ads.getMap("adRules")));
|
|
149
|
+
builder.adRules(adRules);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return builder.build();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private static List<AdBreak> getAdSchedule(ReadableMap ads) {
|
|
156
|
+
List<AdBreak> adScheduleList = new ArrayList<>();
|
|
157
|
+
ReadableArray adSchedule = ads.getArray("adSchedule");
|
|
158
|
+
for (int i = 0; i < adSchedule.size(); i++) {
|
|
159
|
+
ReadableMap adBreakProp = adSchedule.getMap(i);
|
|
160
|
+
String offset = adBreakProp.hasKey("offset") ? adBreakProp.getString("offset") : "pre";
|
|
161
|
+
if (adBreakProp.hasKey("tag")) {
|
|
162
|
+
AdBreak adBreak = new AdBreak.Builder()
|
|
163
|
+
.offset(offset)
|
|
164
|
+
.tag(adBreakProp.getString("tag"))
|
|
165
|
+
.build();
|
|
166
|
+
adScheduleList.add(adBreak);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return adScheduleList;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public static AdRules getAdRules(ReadableMap adRulesMap) {
|
|
173
|
+
AdRules.Builder builder = new AdRules.Builder();
|
|
174
|
+
|
|
175
|
+
if (adRulesMap.hasKey("startOn")) {
|
|
176
|
+
Integer startOn = adRulesMap.getInt("startOn");
|
|
177
|
+
builder.startOn(startOn);
|
|
178
|
+
}
|
|
179
|
+
if (adRulesMap.hasKey("frequency")) {
|
|
180
|
+
Integer frequency = adRulesMap.getInt("frequency");
|
|
181
|
+
builder.frequency(frequency);
|
|
182
|
+
}
|
|
183
|
+
if (adRulesMap.hasKey("timeBetweenAds")) {
|
|
184
|
+
Integer timeBetweenAds = adRulesMap.getInt("timeBetweenAds");
|
|
185
|
+
builder.timeBetweenAds(timeBetweenAds);
|
|
186
|
+
}
|
|
187
|
+
if (adRulesMap.hasKey("startOnSeek")) {
|
|
188
|
+
String startOnSeek = adRulesMap.getString("startOnSeek");
|
|
189
|
+
// Mapping the string to the corresponding constant in AdRules
|
|
190
|
+
String mappedStartOnSeek = mapStartOnSeek(startOnSeek);
|
|
191
|
+
builder.startOnSeek(mappedStartOnSeek);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return builder.build();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private static String mapStartOnSeek(String startOnSeek) {
|
|
198
|
+
if ("pre".equals(startOnSeek)) {
|
|
199
|
+
return AdRules.RULES_START_ON_SEEK_PRE;
|
|
200
|
+
}
|
|
201
|
+
// Default to "none" if not "pre"
|
|
202
|
+
return AdRules.RULES_START_ON_SEEK_NONE;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// public static List<FriendlyObstruction> getFriendlyObstructions(ReadableArray obstructionsArray) {
|
|
206
|
+
// List<FriendlyObstruction> obstructions = new ArrayList<>();
|
|
207
|
+
// // Example: Parse and create FriendlyObstruction objects from obstructionsArray
|
|
208
|
+
// return obstructions;
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
public static ImaSdkSettings getImaSettings(ReadableMap imaSettingsMap) {
|
|
212
|
+
ImaSdkSettings settings = ImaSdkFactory.getInstance().createImaSdkSettings();
|
|
213
|
+
|
|
214
|
+
if (imaSettingsMap.hasKey("maxRedirects")) {
|
|
215
|
+
settings.setMaxRedirects(imaSettingsMap.getInt("maxRedirects"));
|
|
216
|
+
}
|
|
217
|
+
if (imaSettingsMap.hasKey("language")) {
|
|
218
|
+
settings.setLanguage(imaSettingsMap.getString("language"));
|
|
219
|
+
}
|
|
220
|
+
if (imaSettingsMap.hasKey("ppid")) {
|
|
221
|
+
settings.setPpid(imaSettingsMap.getString("ppid"));
|
|
222
|
+
}
|
|
223
|
+
if (imaSettingsMap.hasKey("playerType")) {
|
|
224
|
+
settings.setPlayerType(imaSettingsMap.getString("playerType"));
|
|
225
|
+
}
|
|
226
|
+
if (imaSettingsMap.hasKey("playerVersion")) {
|
|
227
|
+
settings.setPlayerVersion(imaSettingsMap.getString("playerVersion"));
|
|
228
|
+
}
|
|
229
|
+
if (imaSettingsMap.hasKey("sessionId")) {
|
|
230
|
+
settings.setSessionId(imaSettingsMap.getString("sessionId"));
|
|
231
|
+
}
|
|
232
|
+
if (imaSettingsMap.hasKey("debugMode")) {
|
|
233
|
+
settings.setDebugMode(imaSettingsMap.getBoolean("debugMode"));
|
|
234
|
+
}
|
|
235
|
+
// Add other settings as needed
|
|
236
|
+
|
|
237
|
+
return settings;
|
|
238
|
+
}
|
|
239
|
+
}
|