@gcorevideo/player 2.21.1 → 2.21.4

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 (97) hide show
  1. package/assets/audio-selector/style.scss +1 -1
  2. package/assets/audio-selector/track-selector.ejs +3 -3
  3. package/assets/bottom-gear/bottomgear.ejs +2 -2
  4. package/assets/media-control/container.scss +1 -1
  5. package/assets/media-control/media-control.ejs +1 -11
  6. package/assets/media-control/media-control.scss +49 -57
  7. package/assets/media-control/width270.scss +1 -1
  8. package/assets/media-control/width370.scss +7 -9
  9. package/assets/playback-rate/button.ejs +2 -2
  10. package/assets/playback-rate/list.ejs +4 -4
  11. package/assets/subtitles/combobox.ejs +10 -12
  12. package/assets/subtitles/string.ejs +1 -1
  13. package/assets/subtitles/style.scss +9 -16
  14. package/dist/core.js +5 -1
  15. package/dist/index.css +782 -794
  16. package/dist/index.js +240 -244
  17. package/dist/player.d.ts +141 -119
  18. package/dist/plugins/index.css +862 -874
  19. package/dist/plugins/index.js +222 -238
  20. package/docs/api/player.bottomgear.getelement.md +2 -2
  21. package/docs/api/player.bottomgear.md +1 -1
  22. package/docs/api/{player.subtitles.hide.md → player.closedcaptions.hide.md} +2 -2
  23. package/docs/api/{player.subtitles.md → player.closedcaptions.md} +11 -11
  24. package/docs/api/{player.subtitles.show.md → player.closedcaptions.show.md} +2 -2
  25. package/docs/api/player.closedcaptionspluginsettings.md +13 -0
  26. package/docs/api/player.gearitemelement.md +6 -4
  27. package/docs/api/player.gearoptionsitem.md +16 -0
  28. package/docs/api/player.md +48 -12
  29. package/docs/api/player.mediacontrol.putelement.md +2 -2
  30. package/docs/api/player.mediacontrolelement.md +1 -1
  31. package/docs/api/player.playbackrate.md +1 -1
  32. package/docs/api/player.subtitlespluginsettings.md +18 -0
  33. package/docs/api/player.texttrackitem.id.md +11 -0
  34. package/docs/api/player.texttrackitem.md +87 -0
  35. package/docs/api/player.texttrackitem.name.md +11 -0
  36. package/docs/api/player.texttrackitem.track.md +11 -0
  37. package/lib/index.d.ts +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/index.plugins.d.ts +2 -1
  40. package/lib/index.plugins.d.ts.map +1 -1
  41. package/lib/index.plugins.js +2 -1
  42. package/lib/playback/BasePlayback.d.ts +1 -0
  43. package/lib/playback/BasePlayback.d.ts.map +1 -1
  44. package/lib/playback/BasePlayback.js +3 -0
  45. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  46. package/lib/playback/dash-playback/DashPlayback.js +1 -0
  47. package/lib/playback.types.d.ts +5 -0
  48. package/lib/playback.types.d.ts.map +1 -1
  49. package/lib/plugins/audio-selector/AudioSelector.d.ts +2 -3
  50. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  51. package/lib/plugins/audio-selector/AudioSelector.js +6 -7
  52. package/lib/plugins/bottom-gear/BottomGear.d.ts +7 -3
  53. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  54. package/lib/plugins/bottom-gear/BottomGear.js +4 -2
  55. package/lib/plugins/media-control/MediaControl.d.ts +5 -6
  56. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  57. package/lib/plugins/media-control/MediaControl.js +48 -39
  58. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +1 -0
  59. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  60. package/lib/plugins/picture-in-picture/PictureInPicture.js +4 -4
  61. package/lib/plugins/playback-rate/PlaybackRate.d.ts +1 -1
  62. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  63. package/lib/plugins/playback-rate/PlaybackRate.js +24 -14
  64. package/lib/plugins/subtitles/ClosedCaptions.d.ts +118 -0
  65. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -0
  66. package/lib/plugins/subtitles/ClosedCaptions.js +348 -0
  67. package/lib/plugins/subtitles/Subtitles.d.ts +31 -26
  68. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
  69. package/lib/plugins/subtitles/Subtitles.js +138 -169
  70. package/lib/testUtils.d.ts +22 -18
  71. package/lib/testUtils.d.ts.map +1 -1
  72. package/lib/testUtils.js +22 -36
  73. package/package.json +1 -1
  74. package/src/index.plugins.ts +2 -1
  75. package/src/index.ts +1 -1
  76. package/src/playback/BasePlayback.ts +4 -0
  77. package/src/playback/dash-playback/DashPlayback.ts +1 -0
  78. package/src/playback.types.ts +6 -0
  79. package/src/plugins/audio-selector/AudioSelector.ts +9 -8
  80. package/src/plugins/bottom-gear/BottomGear.ts +14 -5
  81. package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +1 -1
  82. package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +2 -2
  83. package/src/plugins/media-control/MediaControl.ts +84 -60
  84. package/src/plugins/media-control/__tests__/MediaControl.test.ts +43 -0
  85. package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +175 -0
  86. package/src/plugins/picture-in-picture/PictureInPicture.ts +5 -5
  87. package/src/plugins/playback-rate/PlaybackRate.ts +143 -100
  88. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +65 -0
  89. package/src/plugins/playback-rate/__tests__/__snapshots__/PlaybackRate.test.ts.snap +11 -0
  90. package/src/plugins/subtitles/ClosedCaptions.ts +469 -0
  91. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +58 -0
  92. package/src/plugins/subtitles/__tests__/__snapshots__/ClosedCaptions.test.ts.snap +25 -0
  93. package/src/testUtils.ts +22 -36
  94. package/temp/player.api.json +269 -89
  95. package/tsconfig.tsbuildinfo +1 -1
  96. package/src/plugins/index.ts +0 -39
  97. package/src/plugins/subtitles/Subtitles.ts +0 -496
package/dist/player.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * It is built on top of the {@link https://github.com/clappr/clappr | Clappr} library and provides a framework for building custom integrations.
7
7
  * Start with {@link Player} for more information.
8
8
  *
9
- * Various plugins (marked with `PLUGIN` keyword) are available to extend the player with additional features.
9
+ * Various plugins (marked with `PLUGIN` keyword) are available to extend the core functionality with additional features.
10
10
  * @example
11
11
  * ```ts
12
12
  * import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
@@ -74,14 +74,13 @@ export declare class AudioSelector extends UICorePlugin {
74
74
  */
75
75
  get attributes(): {
76
76
  class: string;
77
- 'data-track-selector': string;
78
77
  };
79
78
  /**
80
79
  * @internal
81
80
  */
82
81
  get events(): {
83
- 'click [data-track-selector-select]': string;
84
- 'click [data-track-selector-button]': string;
82
+ 'click [data-audiotracks-select]': string;
83
+ 'click [data-audiotracks-button]': string;
85
84
  };
86
85
  /**
87
86
  * @internal
@@ -181,7 +180,7 @@ declare type BitrateTrackRecord = {
181
180
  *
182
181
  * Depends on:
183
182
  *
184
- * - {@link MediaControl | media_control}
183
+ * - {@link MediaControl}
185
184
  */
186
185
  export declare class BottomGear extends UICorePlugin {
187
186
  private isHd;
@@ -220,7 +219,7 @@ export declare class BottomGear extends UICorePlugin {
220
219
  * @param name - Name of a gear menu placeholder item to attach custom UI
221
220
  * @returns Zepto result of the element
222
221
  */
223
- getElement(name: GearItemElement): ZeptoResult | null;
222
+ getElement(name: GearOptionsItem): ZeptoResult | null;
224
223
  /**
225
224
  * Replaces the content of the gear menu
226
225
  * @param content - Zepto result of the element
@@ -486,6 +485,121 @@ export declare interface ClipsPluginSettings {
486
485
  text: string;
487
486
  }
488
487
 
488
+ /**
489
+ * `PLUGIN` that provides a UI to select the subtitles when available.
490
+ * @beta
491
+ *
492
+ * @remarks
493
+ * The plugin is activated when closed captions tracks are provided with the media source.
494
+ * It shows a familiar "CC" button with a dropdown menu to select the subtitles language.
495
+ *
496
+ * Depends on:
497
+ *
498
+ * - {@link MediaControl}
499
+ *
500
+ * Configuration options - {@link ClosedCaptionsPluginSettings}
501
+ * @example
502
+ * ```ts
503
+ * import { ClosedCaptions } from '@gcorevideo/player'
504
+ *
505
+ * Player.registerPlugin(ClosedCaptions)
506
+ *
507
+ * new Player({
508
+ * ...
509
+ * cc: {
510
+ * language: 'en',
511
+ * },
512
+ * })
513
+ * ```
514
+ */
515
+ declare class ClosedCaptions extends UICorePlugin {
516
+ private isPreselectedApplied;
517
+ private isShowing;
518
+ private track;
519
+ private tracks;
520
+ private $line;
521
+ /**
522
+ * @internal
523
+ */
524
+ get name(): string;
525
+ /**
526
+ * @internal
527
+ */
528
+ get supportedVersion(): {
529
+ min: string;
530
+ };
531
+ /**
532
+ * @internal
533
+ */
534
+ static get version(): string;
535
+ private static readonly template;
536
+ private static readonly templateString;
537
+ /**
538
+ * @internal
539
+ */
540
+ get attributes(): {
541
+ class: string;
542
+ };
543
+ /**
544
+ * @internal
545
+ */
546
+ get events(): {
547
+ 'click [data-cc-select]': string;
548
+ 'click [data-cc-button]': string;
549
+ };
550
+ private get preselectedLanguage();
551
+ /**
552
+ * @internal
553
+ */
554
+ bindEvents(): void;
555
+ private onCoreReady;
556
+ private onContainerChanged;
557
+ private onSubtitleAvailable;
558
+ private onSubtitleChanged;
559
+ private applyTracks;
560
+ private onStartAd;
561
+ private onFinishAd;
562
+ private playerResize;
563
+ /**
564
+ * Hides the subtitles menu and the subtitles.
565
+ */
566
+ hide(): void;
567
+ /**
568
+ * Shows the subtitles menu and the subtitles.
569
+ */
570
+ show(): void;
571
+ private shouldRender;
572
+ private resizeFont;
573
+ /**
574
+ * @internal
575
+ */
576
+ render(): this;
577
+ private findById;
578
+ private selectItem;
579
+ private onItemSelect;
580
+ private applyPreselectedSubtitles;
581
+ private hideMenu;
582
+ private toggleMenu;
583
+ private itemElement;
584
+ private allItemElements;
585
+ private selectSubtitles;
586
+ private getSubtitleText;
587
+ private setSubtitleText;
588
+ private clearSubtitleText;
589
+ private updateSelection;
590
+ private highlightCurrentSubtitles;
591
+ private renderIcon;
592
+ }
593
+ export { ClosedCaptions }
594
+ export { ClosedCaptions as Subtitles }
595
+
596
+ export declare type ClosedCaptionsPluginSettings = {
597
+ /**
598
+ * Initially selected subtitles language
599
+ */
600
+ language?: string;
601
+ };
602
+
489
603
  /**
490
604
  * @public
491
605
  */
@@ -756,11 +870,16 @@ export declare interface FaviconPluginSettings {
756
870
  faviconColor?: string;
757
871
  }
758
872
 
873
+ /**
874
+ * @deprecated Use {@link GearOptionsItem} instead
875
+ */
876
+ export declare type GearItemElement = GearOptionsItem;
877
+
759
878
  /**
760
879
  * An element inside the gear menu
761
880
  * @beta
762
881
  */
763
- export declare type GearItemElement = 'quality' | 'rate' | 'nerd';
882
+ export declare type GearOptionsItem = 'quality' | 'rate' | 'nerd';
764
883
 
765
884
  /**
766
885
  * `PLUGIN` that integrates with Google Analytics
@@ -965,7 +1084,6 @@ export { LogTracer }
965
1084
  * The methods exposed are to be used by the other plugins that extend the media control UI.
966
1085
  */
967
1086
  export declare class MediaControl extends UICorePlugin {
968
- private advertisementPlaying;
969
1087
  private buttonsColor;
970
1088
  private currentDurationValue;
971
1089
  private currentPositionValue;
@@ -1007,7 +1125,6 @@ export declare class MediaControl extends UICorePlugin {
1007
1125
  private $seekBarLoaded;
1008
1126
  private $seekBarPosition;
1009
1127
  private $seekBarScrubber;
1010
- private $subtitlesSelector;
1011
1128
  private $volumeBarContainer;
1012
1129
  private $volumeBarBackground;
1013
1130
  private $volumeBarFill;
@@ -1108,7 +1225,7 @@ export declare class MediaControl extends UICorePlugin {
1108
1225
  */
1109
1226
  setInitialVolume(): void;
1110
1227
  private onVolumeChanged;
1111
- private onLoadedMetadataOnVideoTag;
1228
+ private onLoadedMetadata;
1112
1229
  private updateVolumeUI;
1113
1230
  private changeTogglePlay;
1114
1231
  private mousemoveOnSeekBar;
@@ -1150,7 +1267,7 @@ export declare class MediaControl extends UICorePlugin {
1150
1267
  private show;
1151
1268
  private hide;
1152
1269
  private updateCursorStyle;
1153
- private settingsUpdate;
1270
+ private updateSettings;
1154
1271
  private highDefinitionUpdate;
1155
1272
  private createCachedElements;
1156
1273
  /**
@@ -1173,7 +1290,7 @@ export declare class MediaControl extends UICorePlugin {
1173
1290
  * ```
1174
1291
  */
1175
1292
  getElement(name: MediaControlElement): ZeptoResult | null;
1176
- putElement(name: MediaControlElement, element: ZeptoResult): void;
1293
+ putElement(name: MediaControlElement, element: HTMLElement): void;
1177
1294
  /**
1178
1295
  * Get the right panel area to append custom elements to
1179
1296
  * @returns ZeptoSelector of the right panel element
@@ -1218,13 +1335,14 @@ export declare class MediaControl extends UICorePlugin {
1218
1335
  */
1219
1336
  disabledControlButton(): void;
1220
1337
  private isSeekEnabledForHtml5Playback;
1338
+ private getElementLocation;
1221
1339
  }
1222
1340
 
1223
1341
  /**
1224
1342
  * Media control elements, mount points for additional plugins
1225
1343
  * @beta
1226
1344
  */
1227
- export declare type MediaControlElement = 'audioTracksSelector' | 'clipText' | 'gear' | 'pip' | 'playbackRate' | 'seekBarContainer' | 'subtitlesSelector';
1345
+ export declare type MediaControlElement = 'audiotracks' | 'clipText' | 'gear' | 'pip' | 'playbackRate' | 'seekBarContainer' | 'cc';
1228
1346
 
1229
1347
  /**
1230
1348
  * Custom events emitted by the plugins to communicate with one another
@@ -1362,6 +1480,7 @@ export declare class PictureInPicture extends UICorePlugin {
1362
1480
  * @internal
1363
1481
  */
1364
1482
  static get version(): string;
1483
+ private static buttonTemplate;
1365
1484
  /**
1366
1485
  * @internal
1367
1486
  */
@@ -1466,6 +1585,7 @@ export declare type PlaybackModule = 'dash' | 'hls' | 'html5_video';
1466
1585
  * - {@link BottomGear | bottom_gear}
1467
1586
  *
1468
1587
  * It renders a button in the gear menu, which opens a dropdown with the options to change the playback rate.
1588
+ * Note that the playback rate change is supported only for VOD or DVR enabled live streams.
1469
1589
  */
1470
1590
  export declare class PlaybackRate extends UICorePlugin {
1471
1591
  private playbackRates;
@@ -1490,7 +1610,6 @@ export declare class PlaybackRate extends UICorePlugin {
1490
1610
  */
1491
1611
  get attributes(): {
1492
1612
  class: string;
1493
- 'data-playback-rate-select': string;
1494
1613
  };
1495
1614
  /**
1496
1615
  * @internal
@@ -2341,112 +2460,9 @@ export declare interface StartEventData {
2341
2460
  }
2342
2461
 
2343
2462
  /**
2344
- * `PLUGIN` that provides a UI to select the subtitles when available.
2345
- * @beta
2346
- *
2347
- * @remarks
2348
- * Depends on:
2349
- *
2350
- * - {@link MediaControl}
2351
- *
2352
- * Configuration options:
2353
- *
2354
- * - subtitles.language - The language of the subtitles to select by default.
2355
- *
2356
- * @example
2357
- * ```ts
2358
- * import { Subtitles } from '@gcorevideo/player'
2359
- *
2360
- * Player.registerPlugin(Subtitles)
2361
- *
2362
- * new Player({
2363
- * ...
2364
- * subtitles: {
2365
- * language: 'en',
2366
- * },
2367
- * })
2368
- * ```
2463
+ * @deprecated Use {@link ClosedCaptionsPluginSettings} instead.
2369
2464
  */
2370
- export declare class Subtitles extends UICorePlugin {
2371
- private currentLevel;
2372
- private isPreselectedApplied;
2373
- private isShowing;
2374
- private track;
2375
- private tracks;
2376
- private $string;
2377
- /**
2378
- * @internal
2379
- */
2380
- get name(): string;
2381
- /**
2382
- * @internal
2383
- */
2384
- get supportedVersion(): {
2385
- min: string;
2386
- };
2387
- /**
2388
- * @internal
2389
- */
2390
- static get version(): string;
2391
- private static readonly template;
2392
- private static readonly templateString;
2393
- /**
2394
- * @internal
2395
- */
2396
- get attributes(): {
2397
- class: string;
2398
- 'data-subtitles': string;
2399
- };
2400
- /**
2401
- * @internal
2402
- */
2403
- get events(): {
2404
- 'click [data-subtitles-select]': string;
2405
- 'click [data-subtitles-button]': string;
2406
- };
2407
- private get preselectedLanguage();
2408
- /**
2409
- * @internal
2410
- */
2411
- bindEvents(): void;
2412
- private bindPlaybackEvents;
2413
- private getTracks;
2414
- private onStartAd;
2415
- private onFinishAd;
2416
- private playerResize;
2417
- /**
2418
- * Hides the subtitles menu and the subtitles.
2419
- */
2420
- hide(): void;
2421
- /**
2422
- * Shows the subtitles menu and the subtitles.
2423
- */
2424
- show(): void;
2425
- private shouldRender;
2426
- private resizeFont;
2427
- /**
2428
- * @internal
2429
- */
2430
- render(): this;
2431
- private setTracks;
2432
- private findLevelBy;
2433
- private selectLevel;
2434
- private onLevelSelect;
2435
- private applyPreselectedSubtitles;
2436
- private onShowLevelSelectMenu;
2437
- private hideSelectLevelMenu;
2438
- private toggleContextMenu;
2439
- private buttonElement;
2440
- private levelElement;
2441
- private startLevelSwitch;
2442
- private stopLevelSwitch;
2443
- private selectSubtitles;
2444
- private setSubtitleText;
2445
- private clearSubtitleText;
2446
- private updateCurrentLevel;
2447
- private highlightCurrentSubtitles;
2448
- private renderIcon;
2449
- }
2465
+ export declare type SubtitlesPluginSettings = ClosedCaptionsPluginSettings;
2450
2466
 
2451
2467
  /**
2452
2468
  * `PLUGIN` that collects and reports the performance statistics.
@@ -2563,6 +2579,12 @@ export declare type TelemetryRecord = {
2563
2579
  */
2564
2580
  export declare type TelemetrySendFn = (data: TelemetryRecord) => void;
2565
2581
 
2582
+ export declare interface TextTrackItem {
2583
+ id: number;
2584
+ name: string;
2585
+ track: TextTrack;
2586
+ }
2587
+
2566
2588
  /**
2567
2589
  * `PLUGIN` that displays the thumbnails of the video when available.
2568
2590
  * @beta