@capgo/capacitor-video-player 7.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.
Files changed (70) hide show
  1. package/CapgoCapacitorVideoPlayer.podspec +17 -0
  2. package/Package.swift +28 -0
  3. package/README.md +431 -0
  4. package/android/build.gradle +72 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/java/com/capgo/videoplayer/FullscreenExoPlayerFragment.java +1406 -0
  7. package/android/src/main/java/com/capgo/videoplayer/Notifications/MyRunnable.java +21 -0
  8. package/android/src/main/java/com/capgo/videoplayer/Notifications/NotificationCenter.java +61 -0
  9. package/android/src/main/java/com/capgo/videoplayer/PickerVideo/AdapterVideoList.java +47 -0
  10. package/android/src/main/java/com/capgo/videoplayer/PickerVideo/ModelVideo.java +49 -0
  11. package/android/src/main/java/com/capgo/videoplayer/PickerVideo/PickerVideoFragment.java +116 -0
  12. package/android/src/main/java/com/capgo/videoplayer/PickerVideo/VideoRecyclerViewHolder.java +65 -0
  13. package/android/src/main/java/com/capgo/videoplayer/Utilities/FilesUtils.java +38 -0
  14. package/android/src/main/java/com/capgo/videoplayer/Utilities/FragmentUtils.java +32 -0
  15. package/android/src/main/java/com/capgo/videoplayer/VideoPlayer.java +71 -0
  16. package/android/src/main/java/com/capgo/videoplayer/VideoPlayerPlugin.java +1239 -0
  17. package/android/src/main/res/.gitkeep +0 -0
  18. package/android/src/main/res/drawable/bg_round_rect_white_50.xml +9 -0
  19. package/android/src/main/res/drawable/bg_rounded_rectangle_white_corner_rounded.xml +10 -0
  20. package/android/src/main/res/drawable/exo_close_btn.xml +12 -0
  21. package/android/src/main/res/drawable/gradient_transparent_middle.xml +12 -0
  22. package/android/src/main/res/drawable/ic_arrow_left.xml +5 -0
  23. package/android/src/main/res/drawable/ic_baseline_lq.xml +7 -0
  24. package/android/src/main/res/drawable/ic_exo_icon_fastforward.xml +35 -0
  25. package/android/src/main/res/drawable/ic_exo_icon_pause.xml +26 -0
  26. package/android/src/main/res/drawable/ic_exo_icon_play.xml +36 -0
  27. package/android/src/main/res/drawable/ic_exo_icon_rewind.xml +35 -0
  28. package/android/src/main/res/drawable/ic_expand.xml +5 -0
  29. package/android/src/main/res/drawable/ic_fit.xml +5 -0
  30. package/android/src/main/res/drawable/ic_image_background.xml +12 -0
  31. package/android/src/main/res/drawable/ic_img_16_9_background.xml +10 -0
  32. package/android/src/main/res/drawable/ic_img_9_16_background.xml +10 -0
  33. package/android/src/main/res/drawable/ic_outline_lock.xml +5 -0
  34. package/android/src/main/res/drawable/ic_outline_lock_open.xml +5 -0
  35. package/android/src/main/res/drawable/ic_pip_white.xml +5 -0
  36. package/android/src/main/res/drawable/ic_views.xml +18 -0
  37. package/android/src/main/res/drawable/ic_zoom.xml +5 -0
  38. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  39. package/android/src/main/res/layout/exo_playback_control_view.xml +287 -0
  40. package/android/src/main/res/layout/exoplayer_layout_youtube.xml +361 -0
  41. package/android/src/main/res/layout/fragment_fs_exoplayer.xml +50 -0
  42. package/android/src/main/res/layout/fragment_picker_video.xml +21 -0
  43. package/android/src/main/res/layout/row_video.xml +76 -0
  44. package/android/src/main/res/values/colors.xml +14 -0
  45. package/android/src/main/res/values/strings.xml +3 -0
  46. package/android/src/main/res/values/styles.xml +3 -0
  47. package/dist/docs.json +686 -0
  48. package/dist/esm/definitions.d.ts +307 -0
  49. package/dist/esm/definitions.js +2 -0
  50. package/dist/esm/definitions.js.map +1 -0
  51. package/dist/esm/index.d.ts +4 -0
  52. package/dist/esm/index.js +7 -0
  53. package/dist/esm/index.js.map +1 -0
  54. package/dist/esm/web-utils/video-types.d.ts +4 -0
  55. package/dist/esm/web-utils/video-types.js +9 -0
  56. package/dist/esm/web-utils/video-types.js.map +1 -0
  57. package/dist/esm/web-utils/videoplayer.d.ts +30 -0
  58. package/dist/esm/web-utils/videoplayer.js +323 -0
  59. package/dist/esm/web-utils/videoplayer.js.map +1 -0
  60. package/dist/esm/web.d.ts +121 -0
  61. package/dist/esm/web.js +675 -0
  62. package/dist/esm/web.js.map +1 -0
  63. package/dist/plugin.cjs.js +1019 -0
  64. package/dist/plugin.cjs.js.map +1 -0
  65. package/dist/plugin.js +1021 -0
  66. package/dist/plugin.js.map +1 -0
  67. package/ios/Sources/VideoPlayerPlugin/VideoPlayer.swift +8 -0
  68. package/ios/Sources/VideoPlayerPlugin/VideoPlayerPlugin.swift +23 -0
  69. package/ios/Tests/VideoPlayerPluginTests/VideoPlayerPluginTests.swift +15 -0
  70. package/package.json +85 -0
@@ -0,0 +1,675 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import { VideoPlayer } from './web-utils/videoplayer';
3
+ export class VideoPlayerWeb extends WebPlugin {
4
+ constructor() {
5
+ super();
6
+ this._players = [];
7
+ this.addListeners();
8
+ }
9
+ async echo(options) {
10
+ return Promise.resolve({ result: true, method: 'echo', value: options });
11
+ }
12
+ /**
13
+ * Player initialization
14
+ *
15
+ * @param options
16
+ */
17
+ async initPlayer(options) {
18
+ if (options == null) {
19
+ return Promise.resolve({
20
+ result: false,
21
+ method: 'initPlayer',
22
+ message: 'Must provide a capVideoPlayerOptions object',
23
+ });
24
+ }
25
+ this.mode = options.mode ? options.mode : '';
26
+ if (this.mode == null || this.mode.length === 0) {
27
+ return Promise.resolve({
28
+ result: false,
29
+ method: 'initPlayer',
30
+ message: 'Must provide a Mode (fullscreen/embedded)',
31
+ });
32
+ }
33
+ if (this.mode === 'fullscreen' || this.mode === 'embedded') {
34
+ const url = options.url ? options.url : '';
35
+ if (url == null || url.length === 0) {
36
+ return Promise.resolve({
37
+ result: false,
38
+ method: 'initPlayer',
39
+ message: 'Must provide a Video Url',
40
+ });
41
+ }
42
+ if (url == 'internal') {
43
+ return Promise.resolve({
44
+ result: false,
45
+ method: 'initPlayer',
46
+ message: 'Internal Videos not supported on Web Platform',
47
+ });
48
+ }
49
+ const playerId = options.playerId ? options.playerId : '';
50
+ if (playerId == null || playerId.length === 0) {
51
+ return Promise.resolve({
52
+ result: false,
53
+ method: 'initPlayer',
54
+ message: 'Must provide a Player Id',
55
+ });
56
+ }
57
+ const rate = options.rate ? options.rate : 1.0;
58
+ let exitOnEnd = true;
59
+ if (Object.keys(options).includes('exitOnEnd')) {
60
+ const exitRet = options.exitOnEnd;
61
+ exitOnEnd = exitRet != null ? exitRet : true;
62
+ }
63
+ let loopOnEnd = false;
64
+ if (Object.keys(options).includes('loopOnEnd') && !exitOnEnd) {
65
+ const loopRet = options.loopOnEnd;
66
+ loopOnEnd = loopRet != null ? loopRet : false;
67
+ }
68
+ const componentTag = options.componentTag ? options.componentTag : '';
69
+ if (componentTag == null || componentTag.length === 0) {
70
+ return Promise.resolve({
71
+ result: false,
72
+ method: 'initPlayer',
73
+ message: 'Must provide a Component Tag',
74
+ });
75
+ }
76
+ let playerSize = null;
77
+ if (this.mode === 'embedded') {
78
+ playerSize = this.checkSize(options);
79
+ }
80
+ const result = await this._initializeVideoPlayer(url, playerId, this.mode, rate, exitOnEnd, loopOnEnd, componentTag, playerSize);
81
+ return Promise.resolve({ result: result });
82
+ }
83
+ else {
84
+ return Promise.resolve({
85
+ result: false,
86
+ method: 'initPlayer',
87
+ message: 'Must provide a Mode either fullscreen or embedded)',
88
+ });
89
+ }
90
+ }
91
+ /**
92
+ * Return if a given playerId is playing
93
+ *
94
+ * @param options
95
+ */
96
+ async isPlaying(options) {
97
+ if (options == null) {
98
+ return Promise.resolve({
99
+ result: false,
100
+ method: 'isPlaying',
101
+ message: 'Must provide a capVideoPlayerIdOptions object',
102
+ });
103
+ }
104
+ let playerId = options.playerId ? options.playerId : '';
105
+ if (playerId == null || playerId.length === 0) {
106
+ playerId = 'fullscreen';
107
+ }
108
+ if (this._players[playerId]) {
109
+ const playing = this._players[playerId].isPlaying;
110
+ return Promise.resolve({
111
+ method: 'isPlaying',
112
+ result: true,
113
+ value: playing,
114
+ });
115
+ }
116
+ else {
117
+ return Promise.resolve({
118
+ method: 'isPlaying',
119
+ result: false,
120
+ message: 'Given PlayerId does not exist)',
121
+ });
122
+ }
123
+ }
124
+ /**
125
+ * Play the current video from a given playerId
126
+ *
127
+ * @param options
128
+ */
129
+ async play(options) {
130
+ if (options == null) {
131
+ return Promise.resolve({
132
+ result: false,
133
+ method: 'play',
134
+ message: 'Must provide a capVideoPlayerIdOptions object',
135
+ });
136
+ }
137
+ let playerId = options.playerId ? options.playerId : '';
138
+ if (playerId == null || playerId.length === 0) {
139
+ playerId = 'fullscreen';
140
+ }
141
+ if (this._players[playerId]) {
142
+ await this._players[playerId].videoEl.play();
143
+ return Promise.resolve({ method: 'play', result: true, value: true });
144
+ }
145
+ else {
146
+ return Promise.resolve({
147
+ method: 'play',
148
+ result: false,
149
+ message: 'Given PlayerId does not exist)',
150
+ });
151
+ }
152
+ }
153
+ /**
154
+ * Pause the current video from a given playerId
155
+ *
156
+ * @param options
157
+ */
158
+ async pause(options) {
159
+ if (options == null) {
160
+ return Promise.resolve({
161
+ result: false,
162
+ method: 'pause',
163
+ message: 'Must provide a capVideoPlayerIdOptions object',
164
+ });
165
+ }
166
+ let playerId = options.playerId ? options.playerId : '';
167
+ if (playerId == null || playerId.length === 0) {
168
+ playerId = 'fullscreen';
169
+ }
170
+ if (this._players[playerId]) {
171
+ if (this._players[playerId].isPlaying)
172
+ await this._players[playerId].videoEl.pause();
173
+ return Promise.resolve({ method: 'pause', result: true, value: true });
174
+ }
175
+ else {
176
+ return Promise.resolve({
177
+ method: 'pause',
178
+ result: false,
179
+ message: 'Given PlayerId does not exist)',
180
+ });
181
+ }
182
+ }
183
+ /**
184
+ * Get the duration of the current video from a given playerId
185
+ *
186
+ * @param options
187
+ */
188
+ async getDuration(options) {
189
+ if (options == null) {
190
+ return Promise.resolve({
191
+ result: false,
192
+ method: 'getDuration',
193
+ message: 'Must provide a capVideoPlayerIdOptions object',
194
+ });
195
+ }
196
+ let playerId = options.playerId ? options.playerId : '';
197
+ if (playerId == null || playerId.length === 0) {
198
+ playerId = 'fullscreen';
199
+ }
200
+ if (this._players[playerId]) {
201
+ const duration = this._players[playerId].videoEl.duration;
202
+ return Promise.resolve({
203
+ method: 'getDuration',
204
+ result: true,
205
+ value: duration,
206
+ });
207
+ }
208
+ else {
209
+ return Promise.resolve({
210
+ method: 'getDuration',
211
+ result: false,
212
+ message: 'Given PlayerId does not exist)',
213
+ });
214
+ }
215
+ }
216
+ /**
217
+ * Set the rate of the current video from a given playerId
218
+ *
219
+ * @param options
220
+ */
221
+ async setRate(options) {
222
+ if (options == null) {
223
+ return Promise.resolve({
224
+ result: false,
225
+ method: 'setRate',
226
+ message: 'Must provide a capVideoRateOptions object',
227
+ });
228
+ }
229
+ let playerId = options.playerId ? options.playerId : '';
230
+ if (playerId == null || playerId.length === 0) {
231
+ playerId = 'fullscreen';
232
+ }
233
+ const rateList = [0.25, 0.5, 0.75, 1.0, 2.0, 4.0];
234
+ const rate = options.rate && rateList.includes(options.rate) ? options.rate : 1.0;
235
+ if (this._players[playerId]) {
236
+ this._players[playerId].videoEl.playbackRate = rate;
237
+ return Promise.resolve({
238
+ method: 'setRate',
239
+ result: true,
240
+ value: rate,
241
+ });
242
+ }
243
+ else {
244
+ return Promise.resolve({
245
+ method: 'setRate',
246
+ result: false,
247
+ message: 'Given PlayerId does not exist)',
248
+ });
249
+ }
250
+ }
251
+ /**
252
+ * Get the volume of the current video from a given playerId
253
+ *
254
+ * @param options
255
+ */
256
+ async getRate(options) {
257
+ if (options == null) {
258
+ return Promise.resolve({
259
+ result: false,
260
+ method: 'getRate',
261
+ message: 'Must provide a capVideoPlayerIdOptions object',
262
+ });
263
+ }
264
+ let playerId = options.playerId ? options.playerId : '';
265
+ if (playerId == null || playerId.length === 0) {
266
+ playerId = 'fullscreen';
267
+ }
268
+ if (this._players[playerId]) {
269
+ const rate = this._players[playerId].videoEl.playbackRate;
270
+ return Promise.resolve({
271
+ method: 'getRate',
272
+ result: true,
273
+ value: rate,
274
+ });
275
+ }
276
+ else {
277
+ return Promise.resolve({
278
+ method: 'getRate',
279
+ result: false,
280
+ message: 'Given PlayerId does not exist)',
281
+ });
282
+ }
283
+ }
284
+ /**
285
+ * Set the volume of the current video from a given playerId
286
+ *
287
+ * @param options
288
+ */
289
+ async setVolume(options) {
290
+ if (options == null) {
291
+ return Promise.resolve({
292
+ result: false,
293
+ method: 'setVolume',
294
+ message: 'Must provide a capVideoVolumeOptions object',
295
+ });
296
+ }
297
+ let playerId = options.playerId ? options.playerId : '';
298
+ if (playerId == null || playerId.length === 0) {
299
+ playerId = 'fullscreen';
300
+ }
301
+ const volume = options.volume ? options.volume : 0.5;
302
+ if (this._players[playerId]) {
303
+ this._players[playerId].videoEl.volume = volume;
304
+ return Promise.resolve({
305
+ method: 'setVolume',
306
+ result: true,
307
+ value: volume,
308
+ });
309
+ }
310
+ else {
311
+ return Promise.resolve({
312
+ method: 'setVolume',
313
+ result: false,
314
+ message: 'Given PlayerId does not exist)',
315
+ });
316
+ }
317
+ }
318
+ /**
319
+ * Get the volume of the current video from a given playerId
320
+ *
321
+ * @param options
322
+ */
323
+ async getVolume(options) {
324
+ if (options == null) {
325
+ return Promise.resolve({
326
+ result: false,
327
+ method: 'getVolume',
328
+ message: 'Must provide a capVideoPlayerIdOptions object',
329
+ });
330
+ }
331
+ let playerId = options.playerId ? options.playerId : '';
332
+ if (playerId == null || playerId.length === 0) {
333
+ playerId = 'fullscreen';
334
+ }
335
+ if (this._players[playerId]) {
336
+ const volume = this._players[playerId].videoEl.volume;
337
+ return Promise.resolve({
338
+ method: 'getVolume',
339
+ result: true,
340
+ value: volume,
341
+ });
342
+ }
343
+ else {
344
+ return Promise.resolve({
345
+ method: 'getVolume',
346
+ result: false,
347
+ message: 'Given PlayerId does not exist)',
348
+ });
349
+ }
350
+ }
351
+ /**
352
+ * Set the muted property of the current video from a given playerId
353
+ *
354
+ * @param options
355
+ */
356
+ async setMuted(options) {
357
+ if (options == null) {
358
+ return Promise.resolve({
359
+ result: false,
360
+ method: 'setMuted',
361
+ message: 'Must provide a capVideoMutedOptions object',
362
+ });
363
+ }
364
+ let playerId = options.playerId ? options.playerId : '';
365
+ if (playerId == null || playerId.length === 0) {
366
+ playerId = 'fullscreen';
367
+ }
368
+ const muted = options.muted ? options.muted : false;
369
+ if (this._players[playerId]) {
370
+ this._players[playerId].videoEl.muted = muted;
371
+ return Promise.resolve({
372
+ method: 'setMuted',
373
+ result: true,
374
+ value: muted,
375
+ });
376
+ }
377
+ else {
378
+ return Promise.resolve({
379
+ method: 'setMuted',
380
+ result: false,
381
+ message: 'Given PlayerId does not exist)',
382
+ });
383
+ }
384
+ }
385
+ /**
386
+ * Get the muted property of the current video from a given playerId
387
+ *
388
+ * @param options
389
+ */
390
+ async getMuted(options) {
391
+ if (options == null) {
392
+ return Promise.resolve({
393
+ result: false,
394
+ method: 'getMuted',
395
+ message: 'Must provide a capVideoPlayerIdOptions object',
396
+ });
397
+ }
398
+ let playerId = options.playerId ? options.playerId : '';
399
+ if (playerId == null || playerId.length === 0) {
400
+ playerId = 'fullscreen';
401
+ }
402
+ if (this._players[playerId]) {
403
+ const muted = this._players[playerId].videoEl.muted;
404
+ return Promise.resolve({
405
+ method: 'getMuted',
406
+ result: true,
407
+ value: muted,
408
+ });
409
+ }
410
+ else {
411
+ return Promise.resolve({
412
+ method: 'getMuted',
413
+ result: false,
414
+ message: 'Given PlayerId does not exist)',
415
+ });
416
+ }
417
+ }
418
+ /**
419
+ * Set the current time of the current video from a given playerId
420
+ *
421
+ * @param options
422
+ */
423
+ async setCurrentTime(options) {
424
+ if (options == null) {
425
+ return Promise.resolve({
426
+ result: false,
427
+ method: 'setCurrentTime',
428
+ message: 'Must provide a capVideoTimeOptions object',
429
+ });
430
+ }
431
+ let playerId = options.playerId ? options.playerId : '';
432
+ if (playerId == null || playerId.length === 0) {
433
+ playerId = 'fullscreen';
434
+ }
435
+ let seekTime = options.seektime ? options.seektime : 0;
436
+ if (this._players[playerId]) {
437
+ const duration = this._players[playerId].videoEl.duration;
438
+ seekTime = seekTime <= duration && seekTime >= 0 ? seekTime : duration / 2;
439
+ this._players[playerId].videoEl.currentTime = seekTime;
440
+ return Promise.resolve({
441
+ method: 'setCurrentTime',
442
+ result: true,
443
+ value: seekTime,
444
+ });
445
+ }
446
+ else {
447
+ return Promise.resolve({
448
+ method: 'setCurrentTime',
449
+ result: false,
450
+ message: 'Given PlayerId does not exist)',
451
+ });
452
+ }
453
+ }
454
+ /**
455
+ * Get the current time of the current video from a given playerId
456
+ *
457
+ * @param options
458
+ */
459
+ async getCurrentTime(options) {
460
+ if (options == null) {
461
+ return Promise.resolve({
462
+ result: false,
463
+ method: 'getCurrentTime',
464
+ message: 'Must provide a capVideoPlayerIdOptions object',
465
+ });
466
+ }
467
+ let playerId = options.playerId ? options.playerId : '';
468
+ if (playerId == null || playerId.length === 0) {
469
+ playerId = 'fullscreen';
470
+ }
471
+ if (this._players[playerId]) {
472
+ const seekTime = this._players[playerId].videoEl.currentTime;
473
+ return Promise.resolve({
474
+ method: 'getCurrentTime',
475
+ result: true,
476
+ value: seekTime,
477
+ });
478
+ }
479
+ else {
480
+ return Promise.resolve({
481
+ method: 'getCurrentTime',
482
+ result: false,
483
+ message: 'Given PlayerId does not exist)',
484
+ });
485
+ }
486
+ }
487
+ /**
488
+ * Get the current time of the current video from a given playerId
489
+ *
490
+ */
491
+ async stopAllPlayers() {
492
+ for (const i in this._players) {
493
+ if (this._players[i].pipMode) {
494
+ const doc = document;
495
+ if (doc.pictureInPictureElement) {
496
+ await doc.exitPictureInPicture();
497
+ }
498
+ }
499
+ if (!this._players[i].videoEl.paused)
500
+ this._players[i].videoEl.pause();
501
+ }
502
+ return Promise.resolve({
503
+ method: 'stopAllPlayers',
504
+ result: true,
505
+ value: true,
506
+ });
507
+ }
508
+ /**
509
+ * Show controller
510
+ *
511
+ */
512
+ async showController() {
513
+ return Promise.resolve({
514
+ method: 'showController',
515
+ result: true,
516
+ value: true,
517
+ });
518
+ }
519
+ /**
520
+ * isControllerIsFullyVisible
521
+ *
522
+ */
523
+ async isControllerIsFullyVisible() {
524
+ return Promise.resolve({
525
+ method: 'isControllerIsFullyVisible',
526
+ result: true,
527
+ value: true,
528
+ });
529
+ }
530
+ /**
531
+ * Exit the current player
532
+ *
533
+ */
534
+ async exitPlayer() {
535
+ return Promise.resolve({
536
+ method: 'exitPlayer',
537
+ result: true,
538
+ value: true,
539
+ });
540
+ }
541
+ checkSize(options) {
542
+ const playerSize = {
543
+ width: options.width ? options.width : 320,
544
+ height: options.height ? options.height : 180,
545
+ };
546
+ const ratio = playerSize.height / playerSize.width;
547
+ if (playerSize.width > window.innerWidth) {
548
+ playerSize.width = window.innerWidth;
549
+ playerSize.height = Math.floor(playerSize.width * ratio);
550
+ }
551
+ if (playerSize.height > window.innerHeight) {
552
+ playerSize.height = window.innerHeight;
553
+ playerSize.width = Math.floor(playerSize.height / ratio);
554
+ }
555
+ return playerSize;
556
+ }
557
+ async _initializeVideoPlayer(url, playerId, mode, rate, exitOnEnd, loopOnEnd, componentTag, playerSize) {
558
+ const videoURL = url ? (url.indexOf('%2F') == -1 ? encodeURI(url) : url) : null;
559
+ if (videoURL === null)
560
+ return Promise.resolve(false);
561
+ this.videoContainer = await this._getContainerElement(playerId, componentTag);
562
+ if (this.videoContainer === null)
563
+ return Promise.resolve({
564
+ method: 'initPlayer',
565
+ result: false,
566
+ message: 'componentTag or divContainerElement must be provided',
567
+ });
568
+ if (mode === 'embedded' && playerSize == null)
569
+ return Promise.resolve({
570
+ method: 'initPlayer',
571
+ result: false,
572
+ message: 'playerSize must be defined in embedded mode',
573
+ });
574
+ if (mode === 'embedded') {
575
+ this._players[playerId] = new VideoPlayer('embedded', videoURL, playerId, rate, exitOnEnd, loopOnEnd, this.videoContainer, 2, playerSize.width, playerSize.height);
576
+ await this._players[playerId].initialize();
577
+ }
578
+ else if (mode === 'fullscreen') {
579
+ this._players['fullscreen'] = new VideoPlayer('fullscreen', videoURL, 'fullscreen', rate, exitOnEnd, loopOnEnd, this.videoContainer, 99995);
580
+ await this._players['fullscreen'].initialize();
581
+ }
582
+ else {
583
+ return Promise.resolve({
584
+ method: 'initPlayer',
585
+ result: false,
586
+ message: 'mode not supported',
587
+ });
588
+ }
589
+ return Promise.resolve({ method: 'initPlayer', result: true, value: true });
590
+ }
591
+ async _getContainerElement(playerId, componentTag) {
592
+ const videoContainer = document.createElement('div');
593
+ videoContainer.id = `vc_${playerId}`;
594
+ if (componentTag != null && componentTag.length > 0) {
595
+ const cmpTagEl = document.querySelector(`${componentTag}`);
596
+ if (cmpTagEl === null)
597
+ return Promise.resolve(null);
598
+ let container = null;
599
+ const shadowRoot = cmpTagEl.shadowRoot ? cmpTagEl.shadowRoot : null;
600
+ if (shadowRoot != null) {
601
+ container = shadowRoot.querySelector(`[id='${playerId}']`);
602
+ }
603
+ else {
604
+ container = cmpTagEl.querySelector(`[id='${playerId}']`);
605
+ }
606
+ if (container != null)
607
+ container.appendChild(videoContainer);
608
+ return Promise.resolve(videoContainer);
609
+ }
610
+ else {
611
+ return Promise.resolve(null);
612
+ }
613
+ }
614
+ handlePlayerPlay(data) {
615
+ this.notifyListeners('jeepCapVideoPlayerPlay', data);
616
+ }
617
+ handlePlayerPause(data) {
618
+ this.notifyListeners('jeepCapVideoPlayerPause', data);
619
+ }
620
+ handlePlayerEnded(data) {
621
+ var _a;
622
+ if (this.mode === 'fullscreen') {
623
+ (_a = this.videoContainer) === null || _a === void 0 ? void 0 : _a.remove();
624
+ }
625
+ this.removeListeners();
626
+ this.notifyListeners('jeepCapVideoPlayerEnded', data);
627
+ }
628
+ handlePlayerExit() {
629
+ var _a;
630
+ if (this.mode === 'fullscreen') {
631
+ (_a = this.videoContainer) === null || _a === void 0 ? void 0 : _a.remove();
632
+ }
633
+ const retData = { dismiss: true };
634
+ this.removeListeners();
635
+ this.notifyListeners('jeepCapVideoPlayerExit', retData);
636
+ }
637
+ handlePlayerReady(data) {
638
+ this.notifyListeners('jeepCapVideoPlayerReady', data);
639
+ }
640
+ addListeners() {
641
+ document.addEventListener('videoPlayerPlay', (ev) => {
642
+ this.handlePlayerPlay(ev.detail);
643
+ }, false);
644
+ document.addEventListener('videoPlayerPause', (ev) => {
645
+ this.handlePlayerPause(ev.detail);
646
+ }, false);
647
+ document.addEventListener('videoPlayerEnded', (ev) => {
648
+ this.handlePlayerEnded(ev.detail);
649
+ }, false);
650
+ document.addEventListener('videoPlayerReady', (ev) => {
651
+ this.handlePlayerReady(ev.detail);
652
+ }, false);
653
+ document.addEventListener('videoPlayerExit', () => {
654
+ this.handlePlayerExit();
655
+ }, false);
656
+ }
657
+ removeListeners() {
658
+ document.removeEventListener('videoPlayerPlay', (ev) => {
659
+ this.handlePlayerPlay(ev.detail);
660
+ }, false);
661
+ document.removeEventListener('videoPlayerPause', (ev) => {
662
+ this.handlePlayerPause(ev.detail);
663
+ }, false);
664
+ document.removeEventListener('videoPlayerEnded', (ev) => {
665
+ this.handlePlayerEnded(ev.detail);
666
+ }, false);
667
+ document.removeEventListener('videoPlayerReady', (ev) => {
668
+ this.handlePlayerReady(ev.detail);
669
+ }, false);
670
+ document.removeEventListener('videoPlayerExit', () => {
671
+ this.handlePlayerExit();
672
+ }, false);
673
+ }
674
+ }
675
+ //# sourceMappingURL=web.js.map