@mottosports/motto-video-player 1.0.1-rc.49 → 1.0.1-rc.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -399,6 +399,15 @@ interface MuxAnalyticsConfig {
399
399
  metadata?: MuxMetadata;
400
400
  }
401
401
 
402
+ declare global {
403
+ namespace google {
404
+ namespace ima {
405
+ class AdsRequest {
406
+ adTagUrl: string;
407
+ }
408
+ }
409
+ }
410
+ }
402
411
  declare const Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
403
412
 
404
413
  interface VideoProps extends Omit<PlayerProps, 'src'> {
package/dist/index.d.ts CHANGED
@@ -399,6 +399,15 @@ interface MuxAnalyticsConfig {
399
399
  metadata?: MuxMetadata;
400
400
  }
401
401
 
402
+ declare global {
403
+ namespace google {
404
+ namespace ima {
405
+ class AdsRequest {
406
+ adTagUrl: string;
407
+ }
408
+ }
409
+ }
410
+ }
402
411
  declare const Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
403
412
 
404
413
  interface VideoProps extends Omit<PlayerProps, 'src'> {
package/dist/index.js CHANGED
@@ -311,9 +311,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
311
311
  }
312
312
  }
313
313
  @layer utilities {
314
- .pointer-events-auto {
315
- pointer-events: auto;
316
- }
317
314
  .pointer-events-none {
318
315
  pointer-events: none;
319
316
  }
@@ -346,9 +343,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
346
343
  .inset-0 {
347
344
  inset: calc(var(--spacing) * 0);
348
345
  }
349
- .top-0 {
350
- top: calc(var(--spacing) * 0);
351
- }
352
346
  .top-4 {
353
347
  top: calc(var(--spacing) * 4);
354
348
  }
@@ -1163,7 +1157,6 @@ html[dir=rtl] .shaka-overflow-menu .shaka-overflow-button .material-svg-icon:fir
1163
1157
 
1164
1158
  // src/Player.tsx
1165
1159
  var import_react12 = require("react");
1166
- var import_shaka_player4 = __toESM(require("shaka-player/dist/shaka-player.ui"));
1167
1160
 
1168
1161
  // src/hooks/useShakaPlayer.ts
1169
1162
  var import_react = require("react");
@@ -1217,7 +1210,7 @@ var supportsWidevinePersistentLicenses = () => {
1217
1210
  var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
1218
1211
 
1219
1212
  // package.json
1220
- var version = "1.0.1-rc.49";
1213
+ var version = "1.0.1-rc.50";
1221
1214
 
1222
1215
  // src/utils/licenseCache.ts
1223
1216
  var PERSISTENT_LICENSE_PREFIX = "motto_lic_";
@@ -2758,9 +2751,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
2758
2751
  }
2759
2752
  }
2760
2753
  @layer utilities {
2761
- .pointer-events-auto {
2762
- pointer-events: auto;
2763
- }
2764
2754
  .pointer-events-none {
2765
2755
  pointer-events: none;
2766
2756
  }
@@ -2793,9 +2783,6 @@ styleInject(`/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */
2793
2783
  .inset-0 {
2794
2784
  inset: calc(var(--spacing) * 0);
2795
2785
  }
2796
- .top-0 {
2797
- top: calc(var(--spacing) * 0);
2798
- }
2799
2786
  .top-4 {
2800
2787
  top: calc(var(--spacing) * 4);
2801
2788
  }
@@ -3636,7 +3623,6 @@ var Player = (0, import_react12.forwardRef)(
3636
3623
  }, ref) => {
3637
3624
  const videoRef = (0, import_react12.useRef)(null);
3638
3625
  const containerRef = (0, import_react12.useRef)(null);
3639
- const adContainerRef = (0, import_react12.useRef)(null);
3640
3626
  (0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
3641
3627
  const { playerRef, initializePlayer, destroyPlayer, isRetrying } = useShakaPlayer({
3642
3628
  src,
@@ -3703,34 +3689,32 @@ var Player = (0, import_react12.forwardRef)(
3703
3689
  showPulseAnimation: true,
3704
3690
  liveThresholdSeconds: 15
3705
3691
  });
3706
- const initializeAds = () => {
3707
- if (!imaConfig || !playerRef.current || !videoRef.current) return;
3708
- const adManager = playerRef.current.getAdManager();
3709
- if (!adManager) return;
3710
- adManager.addEventListener(import_shaka_player4.default.ads?.Utils?.AD_STARTED, () => {
3711
- events?.onAdStart?.();
3712
- });
3713
- adManager.addEventListener(import_shaka_player4.default.ads?.Utils?.AD_COMPLETE, () => {
3714
- events?.onAdComplete?.();
3715
- });
3716
- adManager.addEventListener(import_shaka_player4.default.ads?.Utils?.AD_ERROR, (event) => {
3717
- events?.onAdError?.(event.detail);
3718
- });
3719
- if (imaConfig.adTagUrl) {
3720
- const adContainer = adContainerRef.current;
3721
- if (adContainer) {
3722
- adManager.initClientSide(adContainer, videoRef.current, imaConfig.adsRenderingSettings);
3723
- const adsRequest = {
3724
- adTagUrl: imaConfig.adTagUrl,
3725
- linearAdSlotWidth: imaConfig.linearAdSlotWidth || width || 640,
3726
- linearAdSlotHeight: imaConfig.linearAdSlotHeight || height || 360,
3727
- nonLinearAdSlotWidth: imaConfig.nonLinearAdSlotWidth || width || 640,
3728
- nonLinearAdSlotHeight: imaConfig.nonLinearAdSlotHeight || 150
3729
- };
3730
- adManager.requestClientSideAds(adsRequest);
3692
+ const initializeAds = (0, import_react12.useCallback)(() => {
3693
+ if (!imaConfig?.adTagUrl || !playerRef.current || !videoRef.current || !uiRef.current) {
3694
+ return;
3695
+ }
3696
+ console.log("Initializing ads...");
3697
+ try {
3698
+ const player = playerRef.current;
3699
+ const video = videoRef.current;
3700
+ const ui = uiRef.current;
3701
+ const controls2 = ui.getControls();
3702
+ const container = controls2.getClientSideAdContainer();
3703
+ const adManager = player.getAdManager();
3704
+ if (!adManager) {
3705
+ console.error("Ad manager not available");
3706
+ return;
3731
3707
  }
3708
+ adManager.initClientSide(container, video);
3709
+ const google = window.google;
3710
+ const adsRequest = new google.ima.AdsRequest();
3711
+ adsRequest.adTagUrl = imaConfig.adTagUrl;
3712
+ adManager.requestClientSideAds(adsRequest);
3713
+ console.log("Ads requested with tag:", imaConfig.adTagUrl);
3714
+ } catch (error) {
3715
+ console.error("Error initializing ads:", error);
3732
3716
  }
3733
- };
3717
+ }, [imaConfig]);
3734
3718
  (0, import_react12.useEffect)(() => {
3735
3719
  const video = videoRef.current;
3736
3720
  if (!video) return;
@@ -3741,7 +3725,9 @@ var Player = (0, import_react12.forwardRef)(
3741
3725
  const cleanupQuality = setupQualityTracking();
3742
3726
  configureQuality();
3743
3727
  await initializeUI();
3744
- initializeAds();
3728
+ if (imaConfig) {
3729
+ initializeAds();
3730
+ }
3745
3731
  } catch (error) {
3746
3732
  console.error("Error during player initialization:", error);
3747
3733
  handleMuxError(error);
@@ -3831,14 +3817,7 @@ var Player = (0, import_react12.forwardRef)(
3831
3817
  ...filteredVideoProps
3832
3818
  }
3833
3819
  ),
3834
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LiveBadge, { isVisible: isLiveBadgeVisible }),
3835
- imaConfig && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3836
- "div",
3837
- {
3838
- ref: adContainerRef,
3839
- className: "absolute top-0 left-0 w-full h-full pointer-events-auto"
3840
- }
3841
- )
3820
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LiveBadge, { isVisible: isLiveBadgeVisible })
3842
3821
  ]
3843
3822
  }
3844
3823
  );