@edm-webplayer/webplayer-angular 0.1.50 → 0.1.52

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.
@@ -172,7 +172,7 @@ class PlyrPlayerComponent {
172
172
  }
173
173
  getOverlaySafeZone() {
174
174
  const host = this.config?.video_host;
175
- if (this.overlayBlockAll && (host === "youtube" || host === "vimeo")) {
175
+ if (this.overlayBlockAll && host === "youtube") {
176
176
  if (this.playbackEnded) {
177
177
  return 0;
178
178
  }
@@ -270,37 +270,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
270
270
  const code = baseLocale.split("-")[0]?.trim();
271
271
  return code ? code.toLowerCase() : null;
272
272
  }
273
- shouldHideVimeoRecommendations() {
274
- const flag = this.config?.disable_vimeo_recommendations;
275
- return flag !== false;
276
- }
277
- clearVimeoEndedState() {
278
- if (this.config.video_host !== "vimeo")
279
- return;
280
- const container = this.plyr?.elements?.container;
281
- container?.classList.remove("plyr--vimeo-ended");
282
- this.toggleRecommendationBlocker(false);
283
- }
284
- preventVimeoRecommendations() {
285
- if (this.config.video_host !== "vimeo")
286
- return;
287
- if (!this.shouldHideVimeoRecommendations())
288
- return;
289
- try {
290
- this.plyr?.stop();
291
- }
292
- catch { }
293
- const embed = this.plyr?.embed;
294
- if (embed && typeof embed.unload === "function") {
295
- try {
296
- embed.unload().catch(() => { });
297
- }
298
- catch { }
299
- }
300
- const container = this.plyr?.elements?.container;
301
- container?.classList.add("plyr--vimeo-ended");
302
- this.toggleRecommendationBlocker(true);
303
- }
304
273
  getVideoWrapper() {
305
274
  const container = this.plyr?.elements?.container;
306
275
  if (!container)
@@ -348,8 +317,7 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
348
317
  return blocker;
349
318
  }
350
319
  toggleRecommendationBlocker(active) {
351
- if (this.config.video_host !== "youtube" &&
352
- this.config.video_host !== "vimeo") {
320
+ if (this.config.video_host !== "youtube") {
353
321
  return;
354
322
  }
355
323
  const blocker = this.ensureRecommendationBlocker();
@@ -438,8 +406,7 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
438
406
  catch { }
439
407
  }
440
408
  ensureTopClickBlocker() {
441
- if (this.config.video_host !== "youtube" &&
442
- this.config.video_host !== "vimeo") {
409
+ if (this.config.video_host !== "youtube") {
443
410
  return;
444
411
  }
445
412
  const wrapper = this.getVideoWrapper();
@@ -509,19 +476,14 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
509
476
  return "ontouchstart" in window;
510
477
  }
511
478
  isIframeProvider() {
512
- return (this.config?.video_host === "youtube" ||
513
- this.config?.video_host === "vimeo");
479
+ return this.config?.video_host === "youtube";
514
480
  }
515
481
  shouldDisableAutoplayForIOS() {
516
482
  return this.isIOSDevice();
517
483
  }
518
- tryEnterVimeoFullscreen() { }
519
- shouldDisableAutoplayForVimeo() {
520
- return this.isIOSDevice() && this.config?.video_host === "vimeo";
521
- }
522
484
  shouldResetProgressToBeginning() {
523
485
  const host = this.config?.video_host;
524
- if (host !== "youtube" && host !== "vimeo") {
486
+ if (host !== "youtube") {
525
487
  return false;
526
488
  }
527
489
  const seenFlag = this.config?.seen;
@@ -545,8 +507,7 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
545
507
  return !!(this.config?.autoplay || this.config?.is_live);
546
508
  }
547
509
  shouldAutoplay() {
548
- if (this.shouldDisableAutoplayForIOS() ||
549
- this.shouldDisableAutoplayForVimeo()) {
510
+ if (this.shouldDisableAutoplayForIOS()) {
550
511
  return false;
551
512
  }
552
513
  return this.wantsAutoplay();
@@ -558,7 +519,7 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
558
519
  return this.wantsAutoplay();
559
520
  }
560
521
  shouldBlockIframeAutoplay() {
561
- return (this.shouldDisableAutoplayForIOS() || this.shouldDisableAutoplayForVimeo());
522
+ return this.shouldDisableAutoplayForIOS();
562
523
  }
563
524
  stopRestrictedIframeAutoplay() {
564
525
  if (!this.shouldBlockIframeAutoplay()) {
@@ -609,34 +570,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
609
570
  catch { }
610
571
  }
611
572
  }
612
- enforceVimeoVolumeAfterPlay(video) {
613
- if (this.config?.video_host !== "vimeo") {
614
- return;
615
- }
616
- const media = video ?? this.videoRef?.nativeElement ?? null;
617
- const volumeTarget = 1;
618
- const attemptRestore = () => {
619
- this.setPlayerMutedState(false, volumeTarget, media);
620
- const currentEmbed = this.plyr?.embed;
621
- if (currentEmbed) {
622
- if (typeof currentEmbed.setMuted === "function") {
623
- try {
624
- currentEmbed.setMuted(false);
625
- }
626
- catch { }
627
- }
628
- if (typeof currentEmbed.setVolume === "function") {
629
- try {
630
- currentEmbed.setVolume(volumeTarget);
631
- }
632
- catch { }
633
- }
634
- }
635
- };
636
- [0, 250, 500, 750].forEach((offset) => {
637
- setTimeout(attemptRestore, 500 + offset);
638
- });
639
- }
640
573
  setPlayerMutedState(muted, volume = 1, target) {
641
574
  if (this.plyr) {
642
575
  try {
@@ -826,17 +759,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
826
759
  if (!Number.isFinite(target) || target < 0) {
827
760
  return null;
828
761
  }
829
- if (this.config.video_host === "vimeo") {
830
- const embed = this.plyr?.embed;
831
- if (embed && typeof embed.setCurrentTime === "function") {
832
- try {
833
- return embed.setCurrentTime(target);
834
- }
835
- catch {
836
- return null;
837
- }
838
- }
839
- }
840
762
  if (video) {
841
763
  try {
842
764
  video.currentTime = target;
@@ -929,14 +851,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
929
851
  catch { }
930
852
  }
931
853
  }
932
- else if (this.config.video_host === "vimeo") {
933
- if (typeof embed.play === "function") {
934
- try {
935
- embed.play();
936
- }
937
- catch { }
938
- }
939
- }
940
854
  }
941
855
  setupControlsVisibility() {
942
856
  const container = this.plyr?.elements?.container;
@@ -1075,8 +989,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1075
989
  const speedOptions = [1, 1.25, 1.5, 2];
1076
990
  const locale = this.resolveLocale();
1077
991
  const captionsLanguage = this.resolveCaptionsLanguage(locale) ?? "pt";
1078
- const hideVimeoRecommendations = this.shouldHideVimeoRecommendations();
1079
- const vimeoPremium = Boolean(this.config?.vimeo_premium);
1080
992
  const shouldAutoplay = this.shouldAutoplay();
1081
993
  const startMuted = this.requiresMutedAutoplay();
1082
994
  try {
@@ -1207,13 +1119,10 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1207
1119
  };
1208
1120
  this.plyr?.on?.("play", () => {
1209
1121
  this.retryPendingStartTime();
1210
- this.clearVimeoEndedState();
1211
1122
  this.playbackEnded = false;
1212
1123
  this.overlayBlockAll = false;
1213
1124
  this.updateRecommendationBlockerSafeZone();
1214
1125
  this.toggleRecommendationBlocker(false);
1215
- this.tryEnterVimeoFullscreen();
1216
- this.enforceVimeoVolumeAfterPlay();
1217
1126
  parent.postMessage("playing_video", "*");
1218
1127
  this.postCastEvent({
1219
1128
  event: "play",
@@ -1245,7 +1154,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1245
1154
  currentTime: this.plyr.currentTime || 0,
1246
1155
  });
1247
1156
  this.progressService.ended$.next();
1248
- this.preventVimeoRecommendations();
1249
1157
  this.toggleRecommendationBlocker(true);
1250
1158
  });
1251
1159
  }
@@ -1301,8 +1209,7 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1301
1209
  this.hls = undefined;
1302
1210
  }
1303
1211
  this.resetPlaybackRate(video);
1304
- if (this.config.video_host === "youtube" ||
1305
- this.config.video_host === "vimeo") {
1212
+ if (this.config.video_host === "youtube") {
1306
1213
  const onReady = () => {
1307
1214
  this.plyr.off("ready", onReady);
1308
1215
  this.ensureIframeAutoplayPermissions();
@@ -1346,12 +1253,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1346
1253
  sources: [{ src: this.config.video_id, provider: "youtube" }],
1347
1254
  };
1348
1255
  }
1349
- else if (this.config.video_host === "vimeo") {
1350
- this.plyr.source = {
1351
- type: "video",
1352
- sources: [{ src: this.config.video_id, provider: "vimeo" }],
1353
- };
1354
- }
1355
1256
  else if (this.config.video_host === "mp4") {
1356
1257
  this.plyr.source = {
1357
1258
  type: "video",
@@ -1505,7 +1406,6 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1505
1406
  this.controlsVisibilityCleanup = undefined;
1506
1407
  this.clearAutoplayUnlockListener();
1507
1408
  const container = this.plyr?.elements?.container;
1508
- container?.classList.remove("plyr--vimeo-ended");
1509
1409
  if (this.recommendationBlocker?.parentElement) {
1510
1410
  try {
1511
1411
  this.recommendationBlocker.parentElement.removeChild(this.recommendationBlocker);
@@ -1537,11 +1437,11 @@ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}
1537
1437
  window.removeEventListener("message", this.onCastMessage);
1538
1438
  }
1539
1439
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PlyrPlayerComponent, deps: [{ token: WebplayerProgressService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1540
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: PlyrPlayerComponent, isStandalone: true, selector: "app-plyr-player", inputs: { config: "config" }, outputs: { ready: "ready" }, viewQueries: [{ propertyName: "videoRef", first: true, predicate: ["video"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `<video #video playsinline></video>`, isInline: true, styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{width:100%!important;height:100%!important;aspect-ratio:auto!important;top:0!important;left:0!important}:host ::ng-deep .mirror{transform:scaleX(-1)!important;-webkit-transform:scaleX(-1)!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}:host ::ng-deep .plyr--vimeo .plyr__video-wrapper.plyr__video-embed{aspect-ratio:16 / 9!important;width:100%!important;height:auto!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
1440
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: PlyrPlayerComponent, isStandalone: true, selector: "app-plyr-player", inputs: { config: "config" }, outputs: { ready: "ready" }, viewQueries: [{ propertyName: "videoRef", first: true, predicate: ["video"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `<video #video playsinline></video>`, isInline: true, styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{width:100%!important;height:100%!important;aspect-ratio:auto!important;top:0!important;left:0!important}:host ::ng-deep .mirror{transform:scaleX(-1)!important;-webkit-transform:scaleX(-1)!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
1541
1441
  }
1542
1442
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PlyrPlayerComponent, decorators: [{
1543
1443
  type: Component,
1544
- args: [{ selector: "app-plyr-player", template: `<video #video playsinline></video>`, standalone: true, imports: [CommonModule], styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{width:100%!important;height:100%!important;aspect-ratio:auto!important;top:0!important;left:0!important}:host ::ng-deep .mirror{transform:scaleX(-1)!important;-webkit-transform:scaleX(-1)!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}:host ::ng-deep .plyr--vimeo .plyr__video-wrapper.plyr__video-embed{aspect-ratio:16 / 9!important;width:100%!important;height:auto!important}\n"] }]
1444
+ args: [{ selector: "app-plyr-player", template: `<video #video playsinline></video>`, standalone: true, imports: [CommonModule], styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{width:100%!important;height:100%!important;aspect-ratio:auto!important;top:0!important;left:0!important}:host ::ng-deep .mirror{transform:scaleX(-1)!important;-webkit-transform:scaleX(-1)!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}\n"] }]
1545
1445
  }], ctorParameters: () => [{ type: WebplayerProgressService }, { type: Document, decorators: [{
1546
1446
  type: Inject,
1547
1447
  args: [DOCUMENT]
@@ -1554,6 +1454,277 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
1554
1454
  type: Output
1555
1455
  }] } });
1556
1456
 
1457
+ class VimeoPlayerComponent {
1458
+ progressService;
1459
+ document;
1460
+ config;
1461
+ ready = new EventEmitter();
1462
+ videoRef;
1463
+ plyr;
1464
+ pendingIOSReload = false;
1465
+ pendingStartOverride;
1466
+ resumeAutoplayAfterSetup = false;
1467
+ onCastMessage = (event) => {
1468
+ let data = event.data;
1469
+ if (typeof data === 'string') {
1470
+ try {
1471
+ data = JSON.parse(data);
1472
+ }
1473
+ catch { }
1474
+ }
1475
+ if (data?.action === 'request-iframe-media-metadata') {
1476
+ this.postCastEvent({
1477
+ event: 'metadata',
1478
+ duration: this.plyr?.duration || 0,
1479
+ currentTime: this.plyr?.currentTime || 0,
1480
+ });
1481
+ }
1482
+ if (data?.action === 'play') {
1483
+ this.plyr?.play?.();
1484
+ }
1485
+ if (data?.action === 'pause') {
1486
+ this.plyr?.pause?.();
1487
+ }
1488
+ if (data?.action === 'seek' && typeof data.time === 'number') {
1489
+ this.plyr && (this.plyr.currentTime = data.time);
1490
+ }
1491
+ };
1492
+ constructor(progressService, document) {
1493
+ this.progressService = progressService;
1494
+ this.document = document;
1495
+ }
1496
+ ngOnInit() {
1497
+ this.applyTheme(this.config?.ui?.colors);
1498
+ }
1499
+ ngAfterViewInit() {
1500
+ this.setupPlayer();
1501
+ }
1502
+ ngOnChanges(changes) {
1503
+ if (changes['config'] && this.plyr) {
1504
+ this.setupPlayer();
1505
+ }
1506
+ }
1507
+ setupPlayer() {
1508
+ if (!this.videoRef) {
1509
+ return;
1510
+ }
1511
+ this.plyr?.destroy();
1512
+ const shouldAutoplay = !!(this.config?.autoplay && !this.isIOSDevice());
1513
+ const startMuted = shouldAutoplay;
1514
+ const speedOptions = [1, 1.25, 1.5, 2];
1515
+ const options = {
1516
+ controls: [
1517
+ 'play-large',
1518
+ 'play',
1519
+ 'progress',
1520
+ 'current-time',
1521
+ 'duration',
1522
+ 'mute',
1523
+ 'volume',
1524
+ 'captions',
1525
+ 'settings',
1526
+ 'pip',
1527
+ 'airplay',
1528
+ 'fullscreen',
1529
+ ],
1530
+ clickToPlay: true,
1531
+ autoplay: shouldAutoplay,
1532
+ muted: startMuted,
1533
+ keyboard: { focused: true, global: false },
1534
+ hideControls: false,
1535
+ i18n: {
1536
+ speed: "Velocidade",
1537
+ },
1538
+ speed: {
1539
+ selected: 1,
1540
+ options: speedOptions,
1541
+ },
1542
+ fullscreen: {
1543
+ enabled: true,
1544
+ fallback: true,
1545
+ iosNative: true,
1546
+ container: null,
1547
+ },
1548
+ };
1549
+ options.vimeo = {
1550
+ autopause: true,
1551
+ autoplay: shouldAutoplay,
1552
+ muted: startMuted,
1553
+ playsinline: !this.isIOSDevice(),
1554
+ byline: false,
1555
+ portrait: false,
1556
+ title: false,
1557
+ pip: false,
1558
+ controls: false,
1559
+ };
1560
+ this.plyr = new Plyr.default(this.videoRef.nativeElement, options);
1561
+ this.plyr.source = {
1562
+ type: 'video',
1563
+ sources: [{ src: this.config.video_id, provider: 'vimeo' }],
1564
+ };
1565
+ this.bindEvents();
1566
+ }
1567
+ bindEvents() {
1568
+ if (!this.plyr)
1569
+ return;
1570
+ let durationPosted = false;
1571
+ const onTimeUpdate = () => {
1572
+ const current = this.plyr.currentTime || 0;
1573
+ const duration = this.plyr.duration || 0;
1574
+ if (!durationPosted && duration > 0) {
1575
+ durationPosted = true;
1576
+ console.log('event: duration ' + duration);
1577
+ parent.postMessage('duration:' + duration, '*');
1578
+ }
1579
+ const percent = duration > 0 ? +((current / duration) * 100).toFixed(2) : 0;
1580
+ this.progressService.progress$.next({ currentTime: current, duration, percent });
1581
+ };
1582
+ this.plyr.on('ready', () => {
1583
+ const duration = this.plyr.duration || 0;
1584
+ const override = this.pendingStartOverride;
1585
+ this.pendingStartOverride = undefined;
1586
+ const start = override ??
1587
+ this.resolveStartTime(this.config.last_time, this.config.last_percent, duration);
1588
+ if (start > 0) {
1589
+ this.plyr.currentTime = start;
1590
+ }
1591
+ console.log('event: ready');
1592
+ if (duration > 0) {
1593
+ parent.postMessage('duration:' + duration, '*');
1594
+ }
1595
+ parent.postMessage('playerIsReadyToPlay', '*');
1596
+ this.ready.emit();
1597
+ if (this.resumeAutoplayAfterSetup) {
1598
+ this.resumeAutoplayAfterSetup = false;
1599
+ try {
1600
+ this.plyr.play?.();
1601
+ }
1602
+ catch { }
1603
+ }
1604
+ });
1605
+ this.plyr.on('timeupdate', onTimeUpdate);
1606
+ this.plyr.on('play', () => {
1607
+ if (this.pendingIOSReload && this.isIOSDevice()) {
1608
+ this.pendingIOSReload = false;
1609
+ this.resumeAutoplayAfterSetup = true;
1610
+ this.pendingStartOverride = this.plyr.currentTime || 0;
1611
+ this.setupPlayer();
1612
+ return;
1613
+ }
1614
+ this.progressService.ended$.next();
1615
+ console.log('event: playing_video');
1616
+ parent.postMessage('playing_video', '*');
1617
+ this.postCastEvent({
1618
+ event: 'play',
1619
+ currentTime: this.plyr.currentTime || 0,
1620
+ });
1621
+ onTimeUpdate();
1622
+ });
1623
+ this.plyr.on('pause', () => {
1624
+ if (this.isIOSDevice()) {
1625
+ this.pendingIOSReload = true;
1626
+ }
1627
+ console.log('event: pause');
1628
+ parent.postMessage('paused_video', '*');
1629
+ this.postCastEvent({
1630
+ event: 'pause',
1631
+ currentTime: this.plyr.currentTime || 0,
1632
+ });
1633
+ onTimeUpdate();
1634
+ });
1635
+ this.plyr.on('ended', () => {
1636
+ console.log('event: ended');
1637
+ parent.postMessage('event: ended', '*');
1638
+ this.postCastEvent({
1639
+ event: 'ended',
1640
+ currentTime: this.plyr.currentTime || 0,
1641
+ });
1642
+ onTimeUpdate();
1643
+ this.progressService.ended$.next();
1644
+ });
1645
+ }
1646
+ resolveStartTime(last_time, last_percent, duration) {
1647
+ const dur = Number(duration) || 0;
1648
+ if (dur <= 0)
1649
+ return 0;
1650
+ if (last_time && Number(last_time) > 0) {
1651
+ return Math.min(Number(last_time), dur - 2);
1652
+ }
1653
+ if (last_percent && Number(last_percent) > 0) {
1654
+ let percent = Number(last_percent);
1655
+ if (percent > 1) {
1656
+ percent = percent / 100;
1657
+ }
1658
+ return Math.min(percent * dur, dur - 2);
1659
+ }
1660
+ return 0;
1661
+ }
1662
+ isIOSDevice() {
1663
+ if (typeof navigator === 'undefined')
1664
+ return false;
1665
+ const ua = navigator.userAgent || '';
1666
+ const iOS = /iPad|iPhone|iPod/.test(ua);
1667
+ const iPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1668
+ return iOS || iPadOS;
1669
+ }
1670
+ ngOnDestroy() {
1671
+ this.plyr?.destroy();
1672
+ if (typeof window !== 'undefined') {
1673
+ window.removeEventListener('message', this.onCastMessage);
1674
+ }
1675
+ this.pendingIOSReload = false;
1676
+ this.pendingStartOverride = undefined;
1677
+ this.resumeAutoplayAfterSetup = false;
1678
+ }
1679
+ postCastEvent(payload) {
1680
+ parent.postMessage(JSON.stringify(payload), '*');
1681
+ }
1682
+ applyTheme(colors) {
1683
+ if (!colors)
1684
+ return;
1685
+ const STYLE_ID = 'webplayer-theme-vars';
1686
+ let styleEl = this.document.getElementById(STYLE_ID);
1687
+ if (!styleEl) {
1688
+ styleEl = this.document.createElement('style');
1689
+ styleEl.id = STYLE_ID;
1690
+ this.document.head.appendChild(styleEl);
1691
+ }
1692
+ const rootStyle = this.document.documentElement.style;
1693
+ const allPairs = [];
1694
+ for (const key in colors) {
1695
+ if (Object.prototype.hasOwnProperty.call(colors, key)) {
1696
+ const cssVarName = `--theme-${key.replace('progresss-', 'progress-')}`;
1697
+ const cssVarValue = String(colors[key]);
1698
+ allPairs.push([cssVarName, cssVarValue]);
1699
+ try {
1700
+ rootStyle.setProperty(cssVarName, cssVarValue);
1701
+ }
1702
+ catch { }
1703
+ }
1704
+ }
1705
+ const cssRule = `:root{
1706
+ ${allPairs.map(([n, v]) => ` ${n}: ${v};`).join('\n')}
1707
+ }`;
1708
+ styleEl.textContent = cssRule;
1709
+ }
1710
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: VimeoPlayerComponent, deps: [{ token: WebplayerProgressService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1711
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: VimeoPlayerComponent, isStandalone: true, selector: "app-vimeo-player", inputs: { config: "config" }, outputs: { ready: "ready" }, viewQueries: [{ propertyName: "videoRef", first: true, predicate: ["video"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `<video #video playsinline></video>`, isInline: true, styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe{width:100%!important;height:100%!important;top:0!important;left:0!important;background:#000!important}:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{max-height:100%!important;object-fit:contain!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}:host ::ng-deep .plyr--vimeo .plyr__video-wrapper.plyr__video-embed{aspect-ratio:16 / 9!important;width:100%!important;height:auto!important}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
1712
+ }
1713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: VimeoPlayerComponent, decorators: [{
1714
+ type: Component,
1715
+ args: [{ selector: 'app-vimeo-player', standalone: true, imports: [CommonModule], template: `<video #video playsinline></video>`, styles: [":host{display:block;width:100%;height:100%;position:relative;--plyr-color-main: var(--theme-alert, #19a6d9);--plyr-color-hover: var(--theme-alert, #2dbbff);--plyr-progress-buffer-background: var( --theme-progress-view-off, rgba(255, 255, 255, .25) );--plyr-control-background: var(--theme-bg, rgba(0, 0, 0, .8));--plyr-control-color: var(--theme-text-color, #fff);--plyr-control-button-color: var(--theme-font-bt, #fff)}:host ::ng-deep .plyr__controls{color:var(--plyr-control-color)!important;transition:opacity .2s ease,transform .2s ease}:host ::ng-deep .plyr__controls button{color:var(--plyr-control-color)!important}:host ::ng-deep .plyr__progress__buffer{background-color:var(--plyr-progress-buffer-background)!important}:host ::ng-deep .plyr,:host ::ng-deep .plyr__video-wrapper,:host ::ng-deep .plyr__video-embed,:host ::ng-deep .plyr__video-embed>iframe{width:100%!important;height:100%!important;top:0!important;left:0!important;background:#000!important}:host ::ng-deep .plyr__video-embed>iframe,:host ::ng-deep video{max-height:100%!important;object-fit:contain!important}:host ::ng-deep .plyr--video .plyr__control.plyr__tab-focus,:host ::ng-deep .plyr--video .plyr__control:hover,:host ::ng-deep .plyr--video .plyr__control[aria-expanded=true]{background:var(--plyr-color-hover)!important;color:var(--plyr-control-button-color)!important}:host ::ng-deep .plyr--full-ui input[type=range]{color:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:var(--plyr-color-main)!important}:host ::ng-deep .plyr__menu__container{background:var(--plyr-control-background)!important;z-index:7!important}:host ::ng-deep .plyr--auto-hide-controls .plyr__controls{opacity:0!important;pointer-events:none!important;transform:translateY(12px)}:host ::ng-deep .ytp-more-videos-view .ytp-suggestions{pointer-events:none!important}:host ::ng-deep .plyr--vimeo .plyr__video-wrapper.plyr__video-embed{aspect-ratio:16 / 9!important;width:100%!important;height:auto!important}\n"] }]
1716
+ }], ctorParameters: () => [{ type: WebplayerProgressService }, { type: Document, decorators: [{
1717
+ type: Inject,
1718
+ args: [DOCUMENT]
1719
+ }] }], propDecorators: { config: [{
1720
+ type: Input
1721
+ }], ready: [{
1722
+ type: Output
1723
+ }], videoRef: [{
1724
+ type: ViewChild,
1725
+ args: ['video', { static: true }]
1726
+ }] } });
1727
+
1557
1728
  class PandaPlayerComponent {
1558
1729
  elementRef;
1559
1730
  progressService;
@@ -2043,11 +2214,11 @@ class PlayerLoaderComponent {
2043
2214
  [config]="config"
2044
2215
  (ready)="onPlayerReady()"
2045
2216
  ></app-plyr-player>
2046
- <app-plyr-player
2217
+ <app-vimeo-player
2047
2218
  *ngSwitchCase="'vimeo'"
2048
2219
  [config]="config"
2049
2220
  (ready)="onPlayerReady()"
2050
- ></app-plyr-player>
2221
+ ></app-vimeo-player>
2051
2222
  <app-panda-player
2052
2223
  *ngSwitchCase="'panda'"
2053
2224
  [config]="config"
@@ -2063,7 +2234,7 @@ class PlayerLoaderComponent {
2063
2234
  </div>
2064
2235
  </div>
2065
2236
  </div>
2066
- `, isInline: true, styles: [":host{display:block;width:100%;height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: PlyrPlayerComponent, selector: "app-plyr-player", inputs: ["config"], outputs: ["ready"] }, { kind: "component", type: PandaPlayerComponent, selector: "app-panda-player", inputs: ["config"], outputs: ["ready"] }, { kind: "component", type: ScaleupPlayerComponent, selector: "app-scaleup-player", inputs: ["config"], outputs: ["ready"] }] });
2237
+ `, isInline: true, styles: [":host{display:block;width:100%;height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: PlyrPlayerComponent, selector: "app-plyr-player", inputs: ["config"], outputs: ["ready"] }, { kind: "component", type: VimeoPlayerComponent, selector: "app-vimeo-player", inputs: ["config"], outputs: ["ready"] }, { kind: "component", type: PandaPlayerComponent, selector: "app-panda-player", inputs: ["config"], outputs: ["ready"] }, { kind: "component", type: ScaleupPlayerComponent, selector: "app-scaleup-player", inputs: ["config"], outputs: ["ready"] }] });
2067
2238
  }
2068
2239
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: PlayerLoaderComponent, decorators: [{
2069
2240
  type: Component,
@@ -2085,11 +2256,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
2085
2256
  [config]="config"
2086
2257
  (ready)="onPlayerReady()"
2087
2258
  ></app-plyr-player>
2088
- <app-plyr-player
2259
+ <app-vimeo-player
2089
2260
  *ngSwitchCase="'vimeo'"
2090
2261
  [config]="config"
2091
2262
  (ready)="onPlayerReady()"
2092
- ></app-plyr-player>
2263
+ ></app-vimeo-player>
2093
2264
  <app-panda-player
2094
2265
  *ngSwitchCase="'panda'"
2095
2266
  [config]="config"
@@ -2108,6 +2279,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
2108
2279
  `, standalone: true, imports: [
2109
2280
  CommonModule,
2110
2281
  PlyrPlayerComponent,
2282
+ VimeoPlayerComponent,
2111
2283
  PandaPlayerComponent,
2112
2284
  ScaleupPlayerComponent,
2113
2285
  ], styles: [":host{display:block;width:100%;height:100%}\n"] }]