@picsa/capacitor-video-player 7.1.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.
Files changed (89) hide show
  1. package/CapacitorVideoPlayer.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/android/build.gradle +71 -0
  4. package/android/src/main/AndroidManifest.xml +3 -0
  5. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayer.java +71 -0
  6. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayerPlugin.java +1256 -0
  7. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/FullscreenExoPlayerFragment.java +1595 -0
  8. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/MyRunnable.java +21 -0
  9. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/NotificationCenter.java +61 -0
  10. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/AdapterVideoList.java +47 -0
  11. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/ModelVideo.java +49 -0
  12. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/PickerVideoFragment.java +119 -0
  13. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/VideoRecyclerViewHolder.java +65 -0
  14. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FilesUtils.java +101 -0
  15. package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FragmentUtils.java +32 -0
  16. package/android/src/main/res/.gitkeep +0 -0
  17. package/android/src/main/res/drawable/bg_round_rect_white_50.xml +9 -0
  18. package/android/src/main/res/drawable/bg_rounded_rectangle_white_corner_rounded.xml +10 -0
  19. package/android/src/main/res/drawable/exo_close_btn.xml +12 -0
  20. package/android/src/main/res/drawable/gradient_transparent_middle.xml +12 -0
  21. package/android/src/main/res/drawable/ic_arrow_left.xml +5 -0
  22. package/android/src/main/res/drawable/ic_baseline_lq.xml +7 -0
  23. package/android/src/main/res/drawable/ic_exo_icon_fastforward.xml +35 -0
  24. package/android/src/main/res/drawable/ic_exo_icon_pause.xml +26 -0
  25. package/android/src/main/res/drawable/ic_exo_icon_play.xml +36 -0
  26. package/android/src/main/res/drawable/ic_exo_icon_rewind.xml +35 -0
  27. package/android/src/main/res/drawable/ic_expand.xml +5 -0
  28. package/android/src/main/res/drawable/ic_fit.xml +5 -0
  29. package/android/src/main/res/drawable/ic_image_background.xml +12 -0
  30. package/android/src/main/res/drawable/ic_img_16_9_background.xml +10 -0
  31. package/android/src/main/res/drawable/ic_img_9_16_background.xml +10 -0
  32. package/android/src/main/res/drawable/ic_outline_lock.xml +5 -0
  33. package/android/src/main/res/drawable/ic_outline_lock_open.xml +5 -0
  34. package/android/src/main/res/drawable/ic_pip_white.xml +5 -0
  35. package/android/src/main/res/drawable/ic_views.xml +18 -0
  36. package/android/src/main/res/drawable/ic_zoom.xml +5 -0
  37. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  38. package/android/src/main/res/layout/exo_playback_control_view.xml +289 -0
  39. package/android/src/main/res/layout/exoplayer_layout_youtube.xml +361 -0
  40. package/android/src/main/res/layout/fragment_fs_exoplayer.xml +50 -0
  41. package/android/src/main/res/layout/fragment_picker_video.xml +21 -0
  42. package/android/src/main/res/layout/row_video.xml +76 -0
  43. package/android/src/main/res/values/colors.xml +14 -0
  44. package/android/src/main/res/values/strings.xml +3 -0
  45. package/android/src/main/res/values/styles.xml +3 -0
  46. package/dist/docs.json +831 -0
  47. package/dist/esm/definitions.d.ts +322 -0
  48. package/dist/esm/definitions.js +2 -0
  49. package/dist/esm/definitions.js.map +1 -0
  50. package/dist/esm/index.d.ts +4 -0
  51. package/dist/esm/index.js +7 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/web-utils/video-types.d.ts +16 -0
  54. package/dist/esm/web-utils/video-types.js +15 -0
  55. package/dist/esm/web-utils/video-types.js.map +1 -0
  56. package/dist/esm/web-utils/videoplayer.d.ts +30 -0
  57. package/dist/esm/web-utils/videoplayer.js +315 -0
  58. package/dist/esm/web-utils/videoplayer.js.map +1 -0
  59. package/dist/esm/web.d.ts +123 -0
  60. package/dist/esm/web.js +675 -0
  61. package/dist/esm/web.js.map +1 -0
  62. package/dist/plugin.cjs.js +1017 -0
  63. package/dist/plugin.cjs.js.map +1 -0
  64. package/dist/plugin.js +1019 -0
  65. package/dist/plugin.js.map +1 -0
  66. package/ios/Plugin/CapacitorVideoPlayer.swift +64 -0
  67. package/ios/Plugin/CapacitorVideoPlayerPlugin.h +10 -0
  68. package/ios/Plugin/CapacitorVideoPlayerPlugin.m +22 -0
  69. package/ios/Plugin/CapacitorVideoPlayerPlugin.swift +632 -0
  70. package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.AVPlayerViewController.swift +59 -0
  71. package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.File.swift +126 -0
  72. package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Fullscreen.swift +94 -0
  73. package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Notifications.swift +140 -0
  74. package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Observers.swift +180 -0
  75. package/ios/Plugin/Info.plist +24 -0
  76. package/ios/Plugin/VideoPicker/VideoHelper.swift +127 -0
  77. package/ios/Plugin/VideoPicker/VideoPickerViewController.swift +144 -0
  78. package/ios/Plugin/VideoPlayer/Extensions/AVURLAsset.swift +18 -0
  79. package/ios/Plugin/VideoPlayer/Extensions/AllOrientationAVPlayerController.swift +12 -0
  80. package/ios/Plugin/VideoPlayer/Extensions/CMTime.swift +23 -0
  81. package/ios/Plugin/VideoPlayer/Extensions/LandscapeAVPlayerController.swift +12 -0
  82. package/ios/Plugin/VideoPlayer/Extensions/Notification.Name.swift +18 -0
  83. package/ios/Plugin/VideoPlayer/Extensions/PortraitAVPlayerController.swift +12 -0
  84. package/ios/Plugin/VideoPlayer/Extensions/View.swift +54 -0
  85. package/ios/Plugin/VideoPlayer/FullScreenVideoPlayerView.swift +601 -0
  86. package/ios/Plugin/VideoPlayer/Models/Video.swift +28 -0
  87. package/ios/Plugin/VideoPlayer/Models/VideoModel.swift +42 -0
  88. package/package.json +92 -0
  89. package/readme.md +190 -0
@@ -0,0 +1,1256 @@
1
+ package com.jeep.plugin.capacitor.capacitorvideoplayer;
2
+
3
+ import android.Manifest;
4
+ import android.app.Activity;
5
+ import android.app.UiModeManager;
6
+ import android.content.Context;
7
+ import android.content.pm.ActivityInfo;
8
+ import android.content.res.Configuration;
9
+ import android.os.Build;
10
+ import android.util.Log;
11
+ import android.view.ViewGroup;
12
+ import android.widget.FrameLayout;
13
+ import android.widget.Toast;
14
+ import androidx.fragment.app.Fragment;
15
+ import com.getcapacitor.Bridge;
16
+ import com.getcapacitor.JSObject;
17
+ import com.getcapacitor.PermissionState;
18
+ import com.getcapacitor.Plugin;
19
+ import com.getcapacitor.PluginCall;
20
+ import com.getcapacitor.PluginMethod;
21
+ import com.getcapacitor.annotation.CapacitorPlugin;
22
+ import com.getcapacitor.annotation.Permission;
23
+ import com.getcapacitor.annotation.PermissionCallback;
24
+ import com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable;
25
+ import com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.NotificationCenter;
26
+ import com.jeep.plugin.capacitor.capacitorvideoplayer.PickerVideo.PickerVideoFragment;
27
+ import com.jeep.plugin.capacitor.capacitorvideoplayer.Utilities.FilesUtils;
28
+ import com.jeep.plugin.capacitor.capacitorvideoplayer.Utilities.FragmentUtils;
29
+ import java.util.HashMap;
30
+ import java.util.Map;
31
+
32
+ @CapacitorPlugin(
33
+ name = "CapacitorVideoPlayer",
34
+ permissions = {
35
+ @Permission(alias = "mediaVideo",
36
+ strings = { Manifest.permission.READ_MEDIA_VIDEO }) ,
37
+ @Permission(alias = "publicStorage",
38
+ strings = { Manifest.permission.READ_EXTERNAL_STORAGE})
39
+ }
40
+ )
41
+ public class CapacitorVideoPlayerPlugin extends Plugin {
42
+
43
+ // Permission alias constants
44
+ private static final String PERMISSION_DENIED_ERROR = "Unable to access media videos, user denied permission request";
45
+
46
+ static final String PUBLICSTORAGE = "publicStorage";
47
+ static final String MEDIAVIDEO = "mediaVideo";
48
+
49
+ private CapacitorVideoPlayer implementation;
50
+ private static final String TAG = "CapacitorVideoPlayer";
51
+ private final int frameLayoutViewId = 256;
52
+ private final int pickerLayoutViewId = 257;
53
+
54
+ private Context context;
55
+ private String videoPath;
56
+ private String subTitlePath;
57
+ private Boolean isTV;
58
+ private String fsPlayerId;
59
+ private String mode;
60
+ private Boolean exitOnEnd = true;
61
+ private Boolean loopOnEnd = false;
62
+ private Boolean pipEnabled = true;
63
+ private Boolean bkModeEnabled = true;
64
+ private Boolean showControls = true;
65
+ private String displayMode = "all";
66
+ private FullscreenExoPlayerFragment fsFragment;
67
+ private PickerVideoFragment pkFragment;
68
+ private FilesUtils filesUtils;
69
+ private JSObject headers;
70
+ private FragmentUtils fragmentUtils;
71
+ private PluginCall call;
72
+ private final Float[] rateList = { 0.25f, 0.5f, 0.75f, 1f, 2f, 4f };
73
+ private Float videoRate = 1f;
74
+ private String title;
75
+ private String smallTitle;
76
+ private String accentColor;
77
+ private Boolean chromecast = true;
78
+ private String artwork;
79
+ private String url;
80
+ private String playerId;
81
+ private String subtitle = "";
82
+ private String language = "";
83
+ private JSObject subTitleOptions;
84
+ private final JSObject ret = new JSObject();
85
+
86
+
87
+
88
+ @Override
89
+ public void load() {
90
+ // Get context
91
+ this.context = getContext();
92
+ implementation = new CapacitorVideoPlayer(this.context);
93
+ this.filesUtils = new FilesUtils(this.context);
94
+ this.fragmentUtils = new FragmentUtils(getBridge());
95
+ }
96
+
97
+ @PermissionCallback
98
+ private void permissionsCallback(PluginCall call) {
99
+ if (!isPermissionsGranted()) {
100
+ call.reject(PERMISSION_DENIED_ERROR);
101
+ return;
102
+ }
103
+ switch (call.getMethodName()) {
104
+ case "initPlayer" -> _initPlayer(call);
105
+ }
106
+ }
107
+
108
+
109
+ @PluginMethod
110
+ public void echo(PluginCall call) {
111
+ String value = call.getString("value");
112
+
113
+ JSObject ret = new JSObject();
114
+ ret.put("value", implementation.echo(value));
115
+ call.resolve(ret);
116
+ }
117
+
118
+ private boolean isPermissionsGranted() {
119
+ String permissionSet = PUBLICSTORAGE;
120
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
121
+ permissionSet = MEDIAVIDEO;
122
+ }
123
+ return getPermissionState(permissionSet) == PermissionState.GRANTED;
124
+ }
125
+
126
+ @PluginMethod
127
+ public void initPlayer(PluginCall call) {
128
+ this.call = call;
129
+ ret.put("method", "initPlayer");
130
+ ret.put("result", false);
131
+ // Check if running on a TV Device
132
+ isTV = isDeviceTV(context);
133
+ Log.d(TAG, "**** isTV " + isTV + " ****");
134
+ String _mode = call.getString("mode");
135
+ if (_mode == null) {
136
+ ret.put("message", "Must provide a Mode (fullscreen/embedded)");
137
+ call.resolve(ret);
138
+ return;
139
+ }
140
+ mode = _mode;
141
+ playerId = call.getString("playerId");
142
+ if (playerId == null) {
143
+ ret.put("message", "Must provide a PlayerId");
144
+ call.resolve(ret);
145
+ return;
146
+ }
147
+ videoRate = 1f;
148
+ if (call.getData().has("rate")) {
149
+ Float mRate = call.getFloat("rate");
150
+ if (isInRate(rateList, mRate)) {
151
+ videoRate = mRate;
152
+ }
153
+ }
154
+ Boolean _exitOnEnd = true;
155
+ if (call.getData().has("exitOnEnd")) {
156
+ _exitOnEnd = call.getBoolean("exitOnEnd");
157
+ }
158
+ exitOnEnd = _exitOnEnd;
159
+ Boolean _loopOnEnd = false;
160
+ if (call.getData().has("loopOnEnd")) {
161
+ _loopOnEnd = call.getBoolean("loopOnEnd");
162
+ }
163
+ if (!exitOnEnd) loopOnEnd = _loopOnEnd;
164
+ Boolean _pipEnabled = true;
165
+ if (call.getData().has("pipEnabled")) {
166
+ _pipEnabled = call.getBoolean("pipEnabled");
167
+ }
168
+ pipEnabled = _pipEnabled;
169
+ Boolean _bkModeEnabled = true;
170
+ if (call.getData().has("bkmodeEnabled")) {
171
+ _bkModeEnabled = call.getBoolean("bkmodeEnabled");
172
+ }
173
+ bkModeEnabled = _bkModeEnabled;
174
+ Boolean _showControls = true;
175
+ if (call.getData().has("showControls")) {
176
+ _showControls = call.getBoolean("showControls");
177
+ }
178
+ showControls = _showControls;
179
+ String _displayMode = "all";
180
+ if (call.getData().has("displayMode")) {
181
+ _displayMode = call.getString("displayMode");
182
+ }
183
+ displayMode = _displayMode;
184
+ if ("fullscreen".equals(mode)) {
185
+ fsPlayerId = playerId;
186
+ url = call.getString("url");
187
+ if (url == null) {
188
+ ret.put("message", "Must provide an url");
189
+ call.resolve(ret);
190
+ return;
191
+ }
192
+ if (call.getData().has("subtitle")) {
193
+ subtitle = call.getString("subtitle");
194
+ }
195
+ if (call.getData().has("language")) {
196
+ language = call.getString("language");
197
+ }
198
+ subTitleOptions = new JSObject();
199
+ if (call.getData().has("subtitleOptions")) {
200
+ subTitleOptions = call.getObject("subtitleOptions");
201
+ }
202
+
203
+ JSObject _headers = new JSObject();
204
+ if (call.getData().has("headers")) {
205
+ _headers = call.getObject("headers");
206
+ }
207
+ headers = _headers;
208
+ String _title = "";
209
+ if (call.getData().has("title")) {
210
+ _title = call.getString("title");
211
+ }
212
+ title = _title;
213
+ String _smallTitle = "";
214
+ if (call.getData().has("smallTitle")) {
215
+ _smallTitle = call.getString("smallTitle");
216
+ }
217
+ smallTitle = _smallTitle;
218
+ String _accentColor = "";
219
+ if (call.getData().has("accentColor")) {
220
+ _accentColor = call.getString("accentColor");
221
+ }
222
+ accentColor = _accentColor;
223
+ Boolean _chromecast = true;
224
+ if (call.getData().has("chromecast")) {
225
+ _chromecast = call.getBoolean("chromecast");
226
+ }
227
+ chromecast = _chromecast;
228
+ String _artwork = "";
229
+ if (call.getData().has("artwork")) {
230
+ _artwork = call.getString("artwork");
231
+ }
232
+ artwork = _artwork;
233
+ AddObserversToNotificationCenter();
234
+ Log.v(TAG, "display url: " + url);
235
+ Log.v(TAG, "display subtitle: " + subtitle);
236
+ Log.v(TAG, "display language: " + language);
237
+ Log.v(TAG, "headers: " + headers);
238
+ Log.v(TAG, "title: " + title);
239
+ Log.v(TAG, "smallTitle: " + smallTitle);
240
+ Log.v(TAG, "accentColor: " + accentColor);
241
+ Log.v(TAG, "chromecast: " + chromecast);
242
+ Log.v(TAG, "artwork: " + artwork);
243
+ if (url.equals("internal") || url.contains("DCIM") || url.contains("Documents")) {
244
+ // Check for permissions to access media video files
245
+ if (isPermissionsGranted()) {
246
+ _initPlayer(call);
247
+ } else {
248
+ this.bridge.saveCall(call);
249
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
250
+ requestPermissionForAlias(MEDIAVIDEO, call, "permissionsCallback");
251
+ } else {
252
+ requestPermissionForAlias(PUBLICSTORAGE, call, "permissionsCallback");
253
+ }
254
+ }
255
+ } else {
256
+ _initPlayer(call);
257
+ }
258
+ } else if ("embedded".equals(mode)) {
259
+ ret.put("message", "Embedded Mode not implemented");
260
+ call.resolve(ret);
261
+ return;
262
+ }
263
+ }
264
+
265
+ @PluginMethod
266
+ public void isPlaying(final PluginCall call) {
267
+ this.call = call;
268
+ JSObject ret = new JSObject();
269
+ ret.put("method", "isPlaying");
270
+ String playerId = call.getString("playerId");
271
+ if (playerId == null) {
272
+ ret.put("result", false);
273
+ ret.put("message", "Must provide a PlayerId");
274
+ call.resolve(ret);
275
+ return;
276
+ }
277
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
278
+ bridge
279
+ .getActivity()
280
+ .runOnUiThread(
281
+ new Runnable() {
282
+ @Override
283
+ public void run() {
284
+ JSObject ret = new JSObject();
285
+ ret.put("method", "isPlaying");
286
+ if (fsFragment != null) {
287
+ boolean playing = fsFragment.isPlaying();
288
+ ret.put("result", true);
289
+ ret.put("value", playing);
290
+ call.resolve(ret);
291
+ } else {
292
+ ret.put("result", false);
293
+ ret.put("message", "Fullscreen fragment is not defined");
294
+ call.resolve(ret);
295
+ }
296
+ }
297
+ }
298
+ );
299
+ } else {
300
+ ret.put("result", false);
301
+ ret.put("message", "player is not defined");
302
+ call.resolve(ret);
303
+ }
304
+ }
305
+
306
+ @PluginMethod
307
+ public void play(final PluginCall call) {
308
+ this.call = call;
309
+ JSObject ret = new JSObject();
310
+ ret.put("method", "play");
311
+ String playerId = call.getString("playerId");
312
+ if (playerId == null) {
313
+ ret.put("result", false);
314
+ ret.put("message", "Must provide a PlayerId");
315
+ call.resolve(ret);
316
+ return;
317
+ }
318
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
319
+ bridge
320
+ .getActivity()
321
+ .runOnUiThread(
322
+ new Runnable() {
323
+ @Override
324
+ public void run() {
325
+ JSObject ret = new JSObject();
326
+ ret.put("method", "play");
327
+ if (fsFragment != null) {
328
+ fsFragment.play();
329
+ boolean playing = fsFragment.isPlaying();
330
+ ret.put("result", true);
331
+ ret.put("value", true);
332
+ call.resolve(ret);
333
+ } else {
334
+ ret.put("result", false);
335
+ ret.put("message", "Fullscreen fragment is not defined");
336
+ call.resolve(ret);
337
+ }
338
+ }
339
+ }
340
+ );
341
+ } else {
342
+ ret.put("result", false);
343
+ ret.put("message", "player is not defined");
344
+ call.resolve(ret);
345
+ }
346
+ }
347
+
348
+ @PluginMethod
349
+ public void pause(final PluginCall call) {
350
+ this.call = call;
351
+ JSObject ret = new JSObject();
352
+ ret.put("method", "pause");
353
+ String playerId = call.getString("playerId");
354
+ if (playerId == null) {
355
+ ret.put("result", false);
356
+ ret.put("message", "Must provide a PlayerId");
357
+ call.resolve(ret);
358
+ return;
359
+ }
360
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
361
+ bridge
362
+ .getActivity()
363
+ .runOnUiThread(
364
+ new Runnable() {
365
+ @Override
366
+ public void run() {
367
+ JSObject ret = new JSObject();
368
+ ret.put("method", "pause");
369
+ if (fsFragment != null) {
370
+ fsFragment.pause();
371
+ ret.put("result", true);
372
+ ret.put("value", true);
373
+ call.resolve(ret);
374
+ } else {
375
+ ret.put("result", false);
376
+ ret.put("message", "Fullscreen fragment is not defined");
377
+ call.resolve(ret);
378
+ }
379
+ }
380
+ }
381
+ );
382
+ } else {
383
+ ret.put("result", false);
384
+ ret.put("message", "player is not defined");
385
+ call.resolve(ret);
386
+ }
387
+ }
388
+
389
+ @PluginMethod
390
+ public void getDuration(final PluginCall call) {
391
+ this.call = call;
392
+ JSObject ret = new JSObject();
393
+ ret.put("method", "getDuration");
394
+ String playerId = call.getString("playerId");
395
+ if (playerId == null) {
396
+ ret.put("result", false);
397
+ ret.put("message", "Must provide a PlayerId");
398
+ call.resolve(ret);
399
+ return;
400
+ }
401
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
402
+ bridge
403
+ .getActivity()
404
+ .runOnUiThread(
405
+ new Runnable() {
406
+ @Override
407
+ public void run() {
408
+ JSObject ret = new JSObject();
409
+ ret.put("method", "getDuration");
410
+ if (fsFragment != null) {
411
+ int duration = fsFragment.getDuration();
412
+ ret.put("result", true);
413
+ ret.put("value", duration);
414
+ call.resolve(ret);
415
+ } else {
416
+ ret.put("result", false);
417
+ ret.put("message", "Fullscreen fragment is not defined");
418
+ call.resolve(ret);
419
+ }
420
+ }
421
+ }
422
+ );
423
+ } else {
424
+ ret.put("result", false);
425
+ ret.put("message", "player is not defined");
426
+ call.resolve(ret);
427
+ }
428
+ }
429
+
430
+ @PluginMethod
431
+ public void getCurrentTime(final PluginCall call) {
432
+ this.call = call;
433
+ JSObject ret = new JSObject();
434
+ ret.put("method", "getCurrentTime");
435
+ String playerId = call.getString("playerId");
436
+ if (playerId == null) {
437
+ ret.put("result", false);
438
+ ret.put("message", "Must provide a PlayerId");
439
+ call.resolve(ret);
440
+ return;
441
+ }
442
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
443
+ bridge
444
+ .getActivity()
445
+ .runOnUiThread(
446
+ new Runnable() {
447
+ @Override
448
+ public void run() {
449
+ JSObject ret = new JSObject();
450
+ ret.put("method", "getCurrentTime");
451
+ if (fsFragment != null) {
452
+ int curTime = fsFragment.getCurrentTime();
453
+ ret.put("result", true);
454
+ ret.put("value", curTime);
455
+ call.resolve(ret);
456
+ } else {
457
+ ret.put("result", false);
458
+ ret.put("message", "Fullscreen fragment is not defined");
459
+ call.resolve(ret);
460
+ }
461
+ }
462
+ }
463
+ );
464
+ } else {
465
+ ret.put("result", false);
466
+ ret.put("message", "player is not defined");
467
+ call.resolve(ret);
468
+ }
469
+ }
470
+
471
+ @PluginMethod
472
+ public void setCurrentTime(final PluginCall call) {
473
+ this.call = call;
474
+ JSObject ret = new JSObject();
475
+ ret.put("method", "setCurrentTime");
476
+ String playerId = call.getString("playerId");
477
+ if (playerId == null) {
478
+ ret.put("result", false);
479
+ ret.put("message", "Must provide a PlayerId");
480
+ call.resolve(ret);
481
+ return;
482
+ }
483
+ Double value = call.getDouble("seektime");
484
+ if (value == null) {
485
+ ret.put("result", false);
486
+ ret.put("message", "Must provide a time in second");
487
+ call.resolve(ret);
488
+ return;
489
+ }
490
+ final int cTime = (int) Math.round(value);
491
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
492
+ bridge
493
+ .getActivity()
494
+ .runOnUiThread(
495
+ new Runnable() {
496
+ @Override
497
+ public void run() {
498
+ JSObject ret = new JSObject();
499
+ ret.put("method", "setCurrentTime");
500
+ if (fsFragment != null) {
501
+ fsFragment.setCurrentTime(cTime);
502
+ ret.put("result", true);
503
+ ret.put("value", cTime);
504
+ call.resolve(ret);
505
+ } else {
506
+ ret.put("result", false);
507
+ ret.put("message", "Fullscreen fragment is not defined");
508
+ call.resolve(ret);
509
+ }
510
+ }
511
+ }
512
+ );
513
+ } else {
514
+ ret.put("result", false);
515
+ ret.put("message", "player is not defined");
516
+ call.resolve(ret);
517
+ }
518
+ }
519
+
520
+ @PluginMethod
521
+ public void getVolume(final PluginCall call) {
522
+ this.call = call;
523
+ JSObject ret = new JSObject();
524
+ ret.put("method", "getVolume");
525
+ String playerId = call.getString("playerId");
526
+ if (playerId == null) {
527
+ ret.put("result", false);
528
+ ret.put("message", "Must provide a PlayerId");
529
+ call.resolve(ret);
530
+ return;
531
+ }
532
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
533
+ bridge
534
+ .getActivity()
535
+ .runOnUiThread(
536
+ new Runnable() {
537
+ @Override
538
+ public void run() {
539
+ JSObject ret = new JSObject();
540
+ ret.put("method", "getVolume");
541
+ if (fsFragment != null) {
542
+ Float volume = fsFragment.getVolume();
543
+ ret.put("result", true);
544
+ ret.put("value", volume);
545
+ call.resolve(ret);
546
+ } else {
547
+ ret.put("result", false);
548
+ ret.put("message", "Fullscreen fragment is not defined");
549
+ call.resolve(ret);
550
+ }
551
+ }
552
+ }
553
+ );
554
+ } else {
555
+ ret.put("result", false);
556
+ ret.put("message", "player is not defined");
557
+ call.resolve(ret);
558
+ }
559
+ }
560
+
561
+ @PluginMethod
562
+ public void setVolume(final PluginCall call) {
563
+ this.call = call;
564
+ JSObject ret = new JSObject();
565
+ ret.put("method", "setVolume");
566
+ String playerId = call.getString("playerId");
567
+ if (playerId == null) {
568
+ ret.put("result", false);
569
+ ret.put("message", "Must provide a PlayerId");
570
+ call.resolve(ret);
571
+ return;
572
+ }
573
+ Float volume = call.getFloat("volume");
574
+ if (volume == null) {
575
+ ret.put("result", false);
576
+ ret.put("method", "setVolume");
577
+ ret.put("message", "Must provide a volume value");
578
+ call.resolve(ret);
579
+ return;
580
+ }
581
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
582
+ bridge
583
+ .getActivity()
584
+ .runOnUiThread(
585
+ new Runnable() {
586
+ @Override
587
+ public void run() {
588
+ JSObject ret = new JSObject();
589
+ ret.put("method", "setVolume");
590
+ if (fsFragment != null) {
591
+ fsFragment.setVolume(volume);
592
+ ret.put("result", true);
593
+ ret.put("value", volume);
594
+ call.resolve(ret);
595
+ } else {
596
+ ret.put("result", false);
597
+ ret.put("message", "Fullscreen fragment is not defined");
598
+ call.resolve(ret);
599
+ }
600
+ }
601
+ }
602
+ );
603
+ } else {
604
+ ret.put("result", false);
605
+ ret.put("message", "player is not defined");
606
+ call.resolve(ret);
607
+ }
608
+ }
609
+
610
+ @PluginMethod
611
+ public void getMuted(final PluginCall call) {
612
+ this.call = call;
613
+ JSObject ret = new JSObject();
614
+ ret.put("method", "getMuted");
615
+ String playerId = call.getString("playerId");
616
+ if (playerId == null) {
617
+ ret.put("result", false);
618
+ ret.put("message", "Must provide a PlayerId");
619
+ call.resolve(ret);
620
+ return;
621
+ }
622
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
623
+ bridge
624
+ .getActivity()
625
+ .runOnUiThread(
626
+ new Runnable() {
627
+ @Override
628
+ public void run() {
629
+ JSObject ret = new JSObject();
630
+ ret.put("method", "getMuted");
631
+ if (fsFragment != null) {
632
+ boolean value = fsFragment.getMuted();
633
+ ret.put("result", true);
634
+ ret.put("value", value);
635
+ call.resolve(ret);
636
+ } else {
637
+ ret.put("result", false);
638
+ ret.put("message", "Fullscreen fragment is not defined");
639
+ call.resolve(ret);
640
+ }
641
+ }
642
+ }
643
+ );
644
+ } else {
645
+ ret.put("result", false);
646
+ ret.put("message", "player is not defined");
647
+ call.resolve(ret);
648
+ }
649
+ }
650
+
651
+ @PluginMethod
652
+ public void setMuted(final PluginCall call) {
653
+ this.call = call;
654
+ JSObject ret = new JSObject();
655
+ ret.put("method", "setMuted");
656
+ String playerId = call.getString("playerId");
657
+ if (playerId == null) {
658
+ ret.put("result", false);
659
+ ret.put("message", "Must provide a PlayerId");
660
+ call.resolve(ret);
661
+ return;
662
+ }
663
+ Boolean value = call.getBoolean("muted");
664
+ if (value == null) {
665
+ ret.put("result", true);
666
+ ret.put("message", "Must provide a boolean true/false");
667
+ call.resolve(ret);
668
+ return;
669
+ }
670
+ final boolean bValue = value;
671
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
672
+ bridge
673
+ .getActivity()
674
+ .runOnUiThread(
675
+ new Runnable() {
676
+ @Override
677
+ public void run() {
678
+ JSObject ret = new JSObject();
679
+ ret.put("method", "setMuted");
680
+ if (fsFragment != null) {
681
+ fsFragment.setMuted(bValue);
682
+ ret.put("result", true);
683
+ ret.put("value", bValue);
684
+ call.resolve(ret);
685
+ } else {
686
+ ret.put("result", false);
687
+ ret.put("message", "Fullscreen fragment is not defined");
688
+ call.resolve(ret);
689
+ }
690
+ }
691
+ }
692
+ );
693
+ } else {
694
+ ret.put("result", false);
695
+ ret.put("message", "player is not defined");
696
+ call.resolve(ret);
697
+ }
698
+ }
699
+
700
+ @PluginMethod
701
+ public void getRate(final PluginCall call) {
702
+ this.call = call;
703
+ JSObject ret = new JSObject();
704
+ ret.put("method", "getRate");
705
+ String playerId = call.getString("playerId");
706
+ if (playerId == null) {
707
+ ret.put("result", false);
708
+ ret.put("message", "Must provide a PlayerId");
709
+ call.resolve(ret);
710
+ return;
711
+ }
712
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
713
+ bridge
714
+ .getActivity()
715
+ .runOnUiThread(
716
+ new Runnable() {
717
+ @Override
718
+ public void run() {
719
+ JSObject ret = new JSObject();
720
+ ret.put("method", "getRate");
721
+ if (fsFragment != null) {
722
+ Float rate = fsFragment.getRate();
723
+ ret.put("result", true);
724
+ ret.put("value", rate);
725
+ call.resolve(ret);
726
+ } else {
727
+ ret.put("result", false);
728
+ ret.put("message", "Fullscreen fragment is not defined");
729
+ call.resolve(ret);
730
+ }
731
+ }
732
+ }
733
+ );
734
+ } else {
735
+ ret.put("result", false);
736
+ ret.put("message", "player is not defined");
737
+ call.resolve(ret);
738
+ }
739
+ }
740
+
741
+ @PluginMethod
742
+ public void setRate(final PluginCall call) {
743
+ this.call = call;
744
+ JSObject ret = new JSObject();
745
+ ret.put("method", "setRate");
746
+ String playerId = call.getString("playerId");
747
+ if (playerId == null) {
748
+ ret.put("result", false);
749
+ ret.put("message", "Must provide a PlayerId");
750
+ call.resolve(ret);
751
+ return;
752
+ }
753
+ Float rate = call.getFloat("rate");
754
+ if (rate == null) {
755
+ ret.put("result", false);
756
+ ret.put("method", "setRate");
757
+ ret.put("message", "Must provide a volume value");
758
+ call.resolve(ret);
759
+ return;
760
+ }
761
+ if (isInRate(rateList, rate)) {
762
+ videoRate = rate;
763
+ } else {
764
+ videoRate = 1f;
765
+ }
766
+ if ("fullscreen".equals(mode) && fsPlayerId.equals(playerId)) {
767
+ bridge
768
+ .getActivity()
769
+ .runOnUiThread(
770
+ new Runnable() {
771
+ @Override
772
+ public void run() {
773
+ JSObject ret = new JSObject();
774
+ ret.put("method", "setRate");
775
+ if (fsFragment != null) {
776
+ fsFragment.setRate(videoRate);
777
+ ret.put("result", true);
778
+ ret.put("value", videoRate);
779
+ call.resolve(ret);
780
+ } else {
781
+ ret.put("result", false);
782
+ ret.put("message", "Fullscreen fragment is not defined");
783
+ call.resolve(ret);
784
+ }
785
+ }
786
+ }
787
+ );
788
+ } else {
789
+ ret.put("result", false);
790
+ ret.put("message", "player is not defined");
791
+ call.resolve(ret);
792
+ }
793
+ }
794
+
795
+ @PluginMethod
796
+ public void stopAllPlayers(PluginCall call) {
797
+ this.call = call;
798
+ bridge
799
+ .getActivity()
800
+ .runOnUiThread(
801
+ new Runnable() {
802
+ @Override
803
+ public void run() {
804
+ JSObject ret = new JSObject();
805
+ ret.put("method", "stopAllPlayers");
806
+ if (fsFragment != null) {
807
+ fsFragment.pause();
808
+ ret.put("result", true);
809
+ ret.put("value", true);
810
+ call.resolve(ret);
811
+ } else {
812
+ ret.put("result", false);
813
+ ret.put("message", "Fullscreen fragment is not defined");
814
+ call.resolve(ret);
815
+ }
816
+ }
817
+ }
818
+ );
819
+ }
820
+
821
+ @PluginMethod
822
+ public void isControllerIsFullyVisible(PluginCall call) {
823
+ this.call = call;
824
+ bridge
825
+ .getActivity()
826
+ .runOnUiThread(
827
+ new Runnable() {
828
+ @Override
829
+ public void run() {
830
+ JSObject ret = new JSObject();
831
+ ret.put("method", "isControllerIsFullyVisible");
832
+ if (fsFragment != null) {
833
+ ret.put("result", true);
834
+ ret.put("value", fsFragment.isControllerIsFullyVisible());
835
+ call.resolve(ret);
836
+ } else {
837
+ ret.put("result", false);
838
+ ret.put("message", "Fullscreen fragment is not defined");
839
+ call.resolve(ret);
840
+ }
841
+ }
842
+ }
843
+ );
844
+ }
845
+
846
+ @PluginMethod
847
+ public void showController(PluginCall call) {
848
+ this.call = call;
849
+ bridge
850
+ .getActivity()
851
+ .runOnUiThread(
852
+ new Runnable() {
853
+ @Override
854
+ public void run() {
855
+ JSObject ret = new JSObject();
856
+ ret.put("method", "showController");
857
+ if (fsFragment != null) {
858
+ fsFragment.showController();
859
+ ret.put("result", true);
860
+ ret.put("value", true);
861
+ call.resolve(ret);
862
+ } else {
863
+ ret.put("result", false);
864
+ ret.put("message", "Fullscreen fragment is not defined");
865
+ call.resolve(ret);
866
+ }
867
+ }
868
+ }
869
+ );
870
+ }
871
+
872
+ @PluginMethod
873
+ public void exitPlayer(PluginCall call) {
874
+ this.call = call;
875
+ bridge
876
+ .getActivity()
877
+ .runOnUiThread(
878
+ new Runnable() {
879
+ @Override
880
+ public void run() {
881
+ JSObject ret = new JSObject();
882
+ ret.put("method", "exitPlayer");
883
+ if (fsFragment != null) {
884
+ fsFragment.playerExit();
885
+ ret.put("result", true);
886
+ ret.put("value", true);
887
+ call.resolve(ret);
888
+ } else {
889
+ ret.put("result", false);
890
+ ret.put("message", "Fullscreen fragment is not defined");
891
+ call.resolve(ret);
892
+ }
893
+ }
894
+ }
895
+ );
896
+ }
897
+
898
+ public boolean isDeviceTV(Context context) {
899
+ //Since Android TV is only API 21+ that is the only time we will compare configurations
900
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
901
+ UiModeManager uiManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
902
+ return uiManager != null && uiManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
903
+ }
904
+ return false;
905
+ }
906
+
907
+ private void _initPlayer(PluginCall call) {
908
+ // Got Permissions ;
909
+ if (url.equals("internal")) {
910
+ createPickerVideoFragment(call);
911
+ } else {
912
+ // get the videoPath
913
+ videoPath = filesUtils.getFilePath(url);
914
+ // get the subTitlePath if any
915
+ if (subtitle != null && subtitle.length() > 0) {
916
+ subTitlePath = filesUtils.getFilePath(subtitle);
917
+ } else {
918
+ subTitlePath = null;
919
+ }
920
+ Log.v(TAG, "*** calculated videoPath: " + videoPath);
921
+ Log.v(TAG, "*** calculated subTitlePath: " + subTitlePath);
922
+ if (videoPath != null) {
923
+ createFullScreenFragment(
924
+ call,
925
+ videoPath,
926
+ videoRate,
927
+ exitOnEnd,
928
+ loopOnEnd,
929
+ pipEnabled,
930
+ bkModeEnabled,
931
+ showControls,
932
+ displayMode,
933
+ subTitlePath,
934
+ language,
935
+ subTitleOptions,
936
+ headers,
937
+ title,
938
+ smallTitle,
939
+ accentColor,
940
+ chromecast,
941
+ artwork,
942
+ isTV,
943
+ playerId,
944
+ false,
945
+ null
946
+ );
947
+ } else {
948
+ Map<String, Object> info = new HashMap<String, Object>() {
949
+ {
950
+ put("dismiss", "1");
951
+ put("currentTime", "0");
952
+ }
953
+ };
954
+ NotificationCenter.defaultCenter().postNotification("playerFullscreenDismiss", info);
955
+ ret.put("message", "initPlayer command failed: Video file not found");
956
+ call.resolve(ret);
957
+ return;
958
+ }
959
+ }
960
+ }
961
+ private Boolean isInRate(Float arr[], Float rate) {
962
+ Boolean ret = false;
963
+ for (Float el : arr) {
964
+ if (el.equals(rate)) {
965
+ ret = true;
966
+ break;
967
+ }
968
+ }
969
+ return ret;
970
+ }
971
+
972
+ private void AddObserversToNotificationCenter() {
973
+ NotificationCenter
974
+ .defaultCenter()
975
+ .addMethodForNotification(
976
+ "playerItemPlay",
977
+ new MyRunnable() {
978
+ @Override
979
+ public void run() {
980
+ JSObject data = new JSObject();
981
+ data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
982
+ data.put("currentTime", this.getInfo().get("currentTime"));
983
+ notifyListeners("jeepCapVideoPlayerPlay", data);
984
+ return;
985
+ }
986
+ }
987
+ );
988
+ NotificationCenter
989
+ .defaultCenter()
990
+ .addMethodForNotification(
991
+ "playerItemPause",
992
+ new MyRunnable() {
993
+ @Override
994
+ public void run() {
995
+ JSObject data = new JSObject();
996
+ data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
997
+ data.put("currentTime", this.getInfo().get("currentTime"));
998
+ notifyListeners("jeepCapVideoPlayerPause", data);
999
+ return;
1000
+ }
1001
+ }
1002
+ );
1003
+ NotificationCenter
1004
+ .defaultCenter()
1005
+ .addMethodForNotification(
1006
+ "playerItemReady",
1007
+ new MyRunnable() {
1008
+ @Override
1009
+ public void run() {
1010
+ JSObject data = new JSObject();
1011
+ data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
1012
+ data.put("currentTime", this.getInfo().get("currentTime"));
1013
+ notifyListeners("jeepCapVideoPlayerReady", data);
1014
+ return;
1015
+ }
1016
+ }
1017
+ );
1018
+ NotificationCenter
1019
+ .defaultCenter()
1020
+ .addMethodForNotification(
1021
+ "playerItemEnd",
1022
+ new MyRunnable() {
1023
+ @Override
1024
+ public void run() {
1025
+ final JSObject data = new JSObject();
1026
+ data.put("fromPlayerId", this.getInfo().get("fromPlayerId"));
1027
+ data.put("currentTime", this.getInfo().get("currentTime"));
1028
+ bridge
1029
+ .getActivity()
1030
+ .runOnUiThread(
1031
+ new Runnable() {
1032
+ @Override
1033
+ public void run() {
1034
+ FrameLayout frameLayoutView = getBridge().getActivity().findViewById(frameLayoutViewId);
1035
+
1036
+ if (frameLayoutView != null) {
1037
+ ((ViewGroup) getBridge().getWebView().getParent()).removeView(frameLayoutView);
1038
+ fragmentUtils.removeFragment(fsFragment);
1039
+ }
1040
+ fsFragment = null;
1041
+ NotificationCenter.defaultCenter().removeAllNotifications();
1042
+ notifyListeners("jeepCapVideoPlayerEnded", data);
1043
+ }
1044
+ }
1045
+ );
1046
+ }
1047
+ }
1048
+ );
1049
+ NotificationCenter
1050
+ .defaultCenter()
1051
+ .addMethodForNotification(
1052
+ "playerFullscreenDismiss",
1053
+ new MyRunnable() {
1054
+ @Override
1055
+ public void run() {
1056
+ boolean ret = false;
1057
+ final JSObject data = new JSObject();
1058
+ if (Integer.valueOf((String) this.getInfo().get("dismiss")) == 1) ret = true;
1059
+ data.put("dismiss", ret);
1060
+ data.put("currentTime", this.getInfo().get("currentTime"));
1061
+ bridge
1062
+ .getActivity()
1063
+ .runOnUiThread(
1064
+ new Runnable() {
1065
+ @Override
1066
+ public void run() {
1067
+ FrameLayout frameLayoutView = getBridge().getActivity().findViewById(frameLayoutViewId);
1068
+
1069
+ if (frameLayoutView != null) {
1070
+ ((ViewGroup) getBridge().getWebView().getParent()).removeView(frameLayoutView);
1071
+ fragmentUtils.removeFragment(fsFragment);
1072
+ }
1073
+ fsFragment = null;
1074
+ NotificationCenter.defaultCenter().removeAllNotifications();
1075
+ notifyListeners("jeepCapVideoPlayerExit", data);
1076
+ }
1077
+ }
1078
+ );
1079
+ }
1080
+ }
1081
+ );
1082
+ NotificationCenter
1083
+ .defaultCenter()
1084
+ .addMethodForNotification(
1085
+ "videoPathInternalReady",
1086
+ new MyRunnable() {
1087
+ @Override
1088
+ public void run() {
1089
+ long videoId = (Long) this.getInfo().get("videoId");
1090
+ // Get the previously saved call
1091
+ FrameLayout pickerLayoutView = getBridge().getActivity().findViewById(pickerLayoutViewId);
1092
+ if (pickerLayoutView != null) {
1093
+ ((ViewGroup) getBridge().getWebView().getParent()).removeView(pickerLayoutView);
1094
+ fragmentUtils.removeFragment(pkFragment);
1095
+ }
1096
+ pkFragment = null;
1097
+ if (videoId != -1) {
1098
+ Log.v(TAG, "§§§§ Notification videoPathInternalReady chromecast: " + chromecast);
1099
+ createFullScreenFragment(
1100
+ call,
1101
+ videoPath,
1102
+ videoRate,
1103
+ exitOnEnd,
1104
+ loopOnEnd,
1105
+ pipEnabled,
1106
+ bkModeEnabled,
1107
+ showControls,
1108
+ displayMode,
1109
+ null,
1110
+ null,
1111
+ null,
1112
+ headers,
1113
+ title,
1114
+ smallTitle,
1115
+ accentColor,
1116
+ chromecast,
1117
+ artwork,
1118
+ isTV,
1119
+ fsPlayerId,
1120
+ true,
1121
+ videoId
1122
+ );
1123
+ } else {
1124
+ Toast.makeText(context, "No Video files found ", Toast.LENGTH_SHORT).show();
1125
+ Map<String, Object> info = new HashMap<String, Object>() {
1126
+ {
1127
+ put("dismiss", "1");
1128
+ put("currentTime", "0");
1129
+ }
1130
+ };
1131
+ NotificationCenter.defaultCenter().postNotification("playerFullscreenDismiss", info);
1132
+ }
1133
+ }
1134
+ }
1135
+ );
1136
+ }
1137
+
1138
+ private void createFullScreenFragment(
1139
+ final PluginCall call,
1140
+ String videoPath,
1141
+ Float videoRate,
1142
+ Boolean exitOnEnd,
1143
+ Boolean loopOnEnd,
1144
+ Boolean pipEnabled,
1145
+ Boolean bkModeEnabled,
1146
+ Boolean showControls,
1147
+ String displayMode,
1148
+ String subTitle,
1149
+ String language,
1150
+ JSObject subTitleOptions,
1151
+ JSObject headers,
1152
+ String title,
1153
+ String smallTitle,
1154
+ String accentColor,
1155
+ Boolean chromecast,
1156
+ String artwork,
1157
+ Boolean isTV,
1158
+ String playerId,
1159
+ Boolean isInternal,
1160
+ Long videoId
1161
+ ) {
1162
+ Log.v(TAG, "§§§§ createFullScreenFragment chromecast: " + chromecast);
1163
+
1164
+ fsFragment =
1165
+ implementation.createFullScreenFragment(
1166
+ videoPath,
1167
+ videoRate,
1168
+ exitOnEnd,
1169
+ loopOnEnd,
1170
+ pipEnabled,
1171
+ bkModeEnabled,
1172
+ showControls,
1173
+ displayMode,
1174
+ subTitle,
1175
+ language,
1176
+ subTitleOptions,
1177
+ headers,
1178
+ title,
1179
+ smallTitle,
1180
+ accentColor,
1181
+ chromecast,
1182
+ artwork,
1183
+ isTV,
1184
+ playerId,
1185
+ isInternal,
1186
+ videoId
1187
+ );
1188
+ bridge
1189
+ .getActivity()
1190
+ .runOnUiThread(
1191
+ new Runnable() {
1192
+ @Override
1193
+ public void run() {
1194
+ JSObject ret = new JSObject();
1195
+ ret.put("method", "initPlayer");
1196
+ FrameLayout frameLayoutView = getBridge().getActivity().findViewById(frameLayoutViewId);
1197
+ if (frameLayoutView != null) {
1198
+ ret.put("result", false);
1199
+ ret.put("message", "FrameLayout for ExoPlayer already exists");
1200
+ } else {
1201
+ // Initialize a new FrameLayout as container for fragment
1202
+ frameLayoutView = new FrameLayout(getActivity().getApplicationContext());
1203
+ frameLayoutView.setId(frameLayoutViewId);
1204
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
1205
+ FrameLayout.LayoutParams.MATCH_PARENT,
1206
+ FrameLayout.LayoutParams.MATCH_PARENT
1207
+ );
1208
+ // Apply the Layout Parameters to frameLayout
1209
+ frameLayoutView.setLayoutParams(lp);
1210
+
1211
+ ((ViewGroup) getBridge().getWebView().getParent()).addView(frameLayoutView);
1212
+ fragmentUtils.loadFragment(fsFragment, frameLayoutViewId);
1213
+ ret.put("result", true);
1214
+ }
1215
+ call.resolve(ret);
1216
+ }
1217
+ }
1218
+ );
1219
+ }
1220
+
1221
+ private void createPickerVideoFragment(final PluginCall call) {
1222
+ pkFragment = implementation.createPickerVideoFragment();
1223
+
1224
+ bridge
1225
+ .getActivity()
1226
+ .runOnUiThread(
1227
+ new Runnable() {
1228
+ @Override
1229
+ public void run() {
1230
+ JSObject ret = new JSObject();
1231
+ ret.put("method", "initPlayer");
1232
+ FrameLayout pickerLayoutView = getBridge().getActivity().findViewById(pickerLayoutViewId);
1233
+ if (pickerLayoutView != null) {
1234
+ ret.put("result", false);
1235
+ ret.put("message", "FrameLayout for VideoPicker already exists");
1236
+ } else {
1237
+ // Initialize a new FrameLayout as container for fragment
1238
+ pickerLayoutView = new FrameLayout(getActivity().getApplicationContext());
1239
+ pickerLayoutView.setId(pickerLayoutViewId);
1240
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
1241
+ FrameLayout.LayoutParams.MATCH_PARENT,
1242
+ FrameLayout.LayoutParams.MATCH_PARENT
1243
+ );
1244
+ // Apply the Layout Parameters to frameLayout
1245
+ pickerLayoutView.setLayoutParams(lp);
1246
+
1247
+ ((ViewGroup) getBridge().getWebView().getParent()).addView(pickerLayoutView);
1248
+ fragmentUtils.loadFragment(pkFragment, pickerLayoutViewId);
1249
+ ret.put("result", true);
1250
+ }
1251
+ call.resolve(ret);
1252
+ }
1253
+ }
1254
+ );
1255
+ }
1256
+ }