@mottosports/motto-video-player 1.0.1-rc.25 → 1.0.1-rc.27

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
@@ -1,6 +1,72 @@
1
1
  import React, { HTMLAttributes } from 'react';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
 
4
+ interface VideoData {
5
+ id: string;
6
+ name?: string;
7
+ description?: string;
8
+ playlists?: Playlist[];
9
+ error?: string;
10
+ }
11
+ interface DVRSettings {
12
+ window_size_seconds: number;
13
+ }
14
+ interface Widevine {
15
+ playlist_url: string;
16
+ license_url: string;
17
+ }
18
+ interface Fairplay {
19
+ certificate_url: string;
20
+ license_url: string;
21
+ playlist_url: string;
22
+ }
23
+ interface Playready {
24
+ playlist_url: string;
25
+ license_url: string;
26
+ }
27
+ interface DRM {
28
+ token?: string;
29
+ widevine?: Widevine;
30
+ fairplay?: Fairplay;
31
+ playready?: Playready;
32
+ }
33
+ interface Playlist {
34
+ url: string;
35
+ format: string;
36
+ dvr_settings?: DVRSettings;
37
+ drm: DRM;
38
+ }
39
+
40
+ interface EventData {
41
+ id: string;
42
+ title: string;
43
+ description?: string;
44
+ startTime: string;
45
+ endTime?: string;
46
+ posterUrl?: string;
47
+ videoIds?: string[];
48
+ error?: string;
49
+ }
50
+ declare enum EventsSortDirection {
51
+ ASC = "asc",
52
+ DESC = "desc"
53
+ }
54
+
55
+ interface CreativeWorkData {
56
+ id: string;
57
+ title: string;
58
+ description?: string;
59
+ releaseTime: string;
60
+ endTime?: string;
61
+ posterUrl?: string;
62
+ videoIds?: string[];
63
+ error?: string;
64
+ }
65
+ declare enum CreativeWorksSortDirection {
66
+ ASC = "asc",
67
+ DESC = "desc"
68
+ }
69
+
4
70
  /**
5
71
  * Unified events interface for both Player and Video wrapper
6
72
  */
@@ -111,7 +177,7 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
111
177
  /**
112
178
  * The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info
113
179
  */
114
- src: string | any;
180
+ src: Playlist;
115
181
  /**
116
182
  * Whether the video should autoplay
117
183
  */
@@ -339,81 +405,6 @@ interface MuxAnalyticsConfig {
339
405
 
340
406
  declare const Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
341
407
 
342
- interface VideoData {
343
- id: string;
344
- name?: string;
345
- description?: string;
346
- playlists?: Array<{
347
- url: string;
348
- format: string;
349
- }>;
350
- error?: string;
351
- }
352
- interface DRMSettings {
353
- window_size_seconds: number;
354
- }
355
- interface Widevine {
356
- playlist_url: string;
357
- license_url: string;
358
- }
359
- interface Fairplay {
360
- certificate_url: string;
361
- license_url: string;
362
- playlist_url: string;
363
- }
364
- interface Playready {
365
- playlist_url: string;
366
- license_url: string;
367
- }
368
- interface DRM {
369
- token?: string;
370
- widevine?: Widevine;
371
- fairplay?: Fairplay;
372
- playready?: Playready;
373
- }
374
- interface VideoListItem {
375
- id: string;
376
- name?: string;
377
- description?: string;
378
- playlists?: Array<{
379
- url: string;
380
- format: string;
381
- drm_settings: DRMSettings;
382
- drm: DRM;
383
- }>;
384
- error?: string;
385
- }
386
-
387
- interface EventData {
388
- id: string;
389
- title: string;
390
- description?: string;
391
- startTime: string;
392
- endTime?: string;
393
- posterUrl?: string;
394
- videoIds?: string[];
395
- error?: string;
396
- }
397
- declare enum EventsSortDirection {
398
- ASC = "asc",
399
- DESC = "desc"
400
- }
401
-
402
- interface CreativeWorkData {
403
- id: string;
404
- title: string;
405
- description?: string;
406
- releaseTime: string;
407
- endTime?: string;
408
- posterUrl?: string;
409
- videoIds?: string[];
410
- error?: string;
411
- }
412
- declare enum CreativeWorksSortDirection {
413
- ASC = "asc",
414
- DESC = "desc"
415
- }
416
-
417
408
  interface VideoProps extends Omit<PlayerProps, 'src'> {
418
409
  videoId?: string;
419
410
  publicKey?: string;
@@ -460,7 +451,7 @@ interface EventProps extends Omit<PlayerProps, 'src' | 'drmConfig'> {
460
451
  order?: EventsSortDirection;
461
452
  events?: {
462
453
  onEventData?: (event: EventData) => void;
463
- onVideoData?: (video: VideoListItem) => void;
454
+ onVideoData?: (video: VideoData) => void;
464
455
  onEmptyPlaylists?: () => void;
465
456
  onError?: (error: Error) => void;
466
457
  onPlay?: () => void;
@@ -498,7 +489,7 @@ interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
498
489
  order?: CreativeWorksSortDirection;
499
490
  events?: {
500
491
  onCreativeWorkData?: (creativeWork: CreativeWorkData) => void;
501
- onVideoData?: (video: VideoListItem) => void;
492
+ onVideoData?: (video: VideoData) => void;
502
493
  onEmptyPlaylists?: () => void;
503
494
  onError?: (error: Error) => void;
504
495
  onPlay?: () => void;
@@ -551,4 +542,4 @@ interface BigPlayIconProps {
551
542
  }
552
543
  declare const BigPlayIcon: React.FC<BigPlayIconProps>;
553
544
 
554
- export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
545
+ export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoProps, queryClient };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,72 @@
1
1
  import React, { HTMLAttributes } from 'react';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
 
4
+ interface VideoData {
5
+ id: string;
6
+ name?: string;
7
+ description?: string;
8
+ playlists?: Playlist[];
9
+ error?: string;
10
+ }
11
+ interface DVRSettings {
12
+ window_size_seconds: number;
13
+ }
14
+ interface Widevine {
15
+ playlist_url: string;
16
+ license_url: string;
17
+ }
18
+ interface Fairplay {
19
+ certificate_url: string;
20
+ license_url: string;
21
+ playlist_url: string;
22
+ }
23
+ interface Playready {
24
+ playlist_url: string;
25
+ license_url: string;
26
+ }
27
+ interface DRM {
28
+ token?: string;
29
+ widevine?: Widevine;
30
+ fairplay?: Fairplay;
31
+ playready?: Playready;
32
+ }
33
+ interface Playlist {
34
+ url: string;
35
+ format: string;
36
+ dvr_settings?: DVRSettings;
37
+ drm: DRM;
38
+ }
39
+
40
+ interface EventData {
41
+ id: string;
42
+ title: string;
43
+ description?: string;
44
+ startTime: string;
45
+ endTime?: string;
46
+ posterUrl?: string;
47
+ videoIds?: string[];
48
+ error?: string;
49
+ }
50
+ declare enum EventsSortDirection {
51
+ ASC = "asc",
52
+ DESC = "desc"
53
+ }
54
+
55
+ interface CreativeWorkData {
56
+ id: string;
57
+ title: string;
58
+ description?: string;
59
+ releaseTime: string;
60
+ endTime?: string;
61
+ posterUrl?: string;
62
+ videoIds?: string[];
63
+ error?: string;
64
+ }
65
+ declare enum CreativeWorksSortDirection {
66
+ ASC = "asc",
67
+ DESC = "desc"
68
+ }
69
+
4
70
  /**
5
71
  * Unified events interface for both Player and Video wrapper
6
72
  */
@@ -111,7 +177,7 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
111
177
  /**
112
178
  * The source URL of the video (DASH, HLS, or regular MP4) or playlist object with DRM info
113
179
  */
114
- src: string | any;
180
+ src: Playlist;
115
181
  /**
116
182
  * Whether the video should autoplay
117
183
  */
@@ -339,81 +405,6 @@ interface MuxAnalyticsConfig {
339
405
 
340
406
  declare const Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
341
407
 
342
- interface VideoData {
343
- id: string;
344
- name?: string;
345
- description?: string;
346
- playlists?: Array<{
347
- url: string;
348
- format: string;
349
- }>;
350
- error?: string;
351
- }
352
- interface DRMSettings {
353
- window_size_seconds: number;
354
- }
355
- interface Widevine {
356
- playlist_url: string;
357
- license_url: string;
358
- }
359
- interface Fairplay {
360
- certificate_url: string;
361
- license_url: string;
362
- playlist_url: string;
363
- }
364
- interface Playready {
365
- playlist_url: string;
366
- license_url: string;
367
- }
368
- interface DRM {
369
- token?: string;
370
- widevine?: Widevine;
371
- fairplay?: Fairplay;
372
- playready?: Playready;
373
- }
374
- interface VideoListItem {
375
- id: string;
376
- name?: string;
377
- description?: string;
378
- playlists?: Array<{
379
- url: string;
380
- format: string;
381
- drm_settings: DRMSettings;
382
- drm: DRM;
383
- }>;
384
- error?: string;
385
- }
386
-
387
- interface EventData {
388
- id: string;
389
- title: string;
390
- description?: string;
391
- startTime: string;
392
- endTime?: string;
393
- posterUrl?: string;
394
- videoIds?: string[];
395
- error?: string;
396
- }
397
- declare enum EventsSortDirection {
398
- ASC = "asc",
399
- DESC = "desc"
400
- }
401
-
402
- interface CreativeWorkData {
403
- id: string;
404
- title: string;
405
- description?: string;
406
- releaseTime: string;
407
- endTime?: string;
408
- posterUrl?: string;
409
- videoIds?: string[];
410
- error?: string;
411
- }
412
- declare enum CreativeWorksSortDirection {
413
- ASC = "asc",
414
- DESC = "desc"
415
- }
416
-
417
408
  interface VideoProps extends Omit<PlayerProps, 'src'> {
418
409
  videoId?: string;
419
410
  publicKey?: string;
@@ -460,7 +451,7 @@ interface EventProps extends Omit<PlayerProps, 'src' | 'drmConfig'> {
460
451
  order?: EventsSortDirection;
461
452
  events?: {
462
453
  onEventData?: (event: EventData) => void;
463
- onVideoData?: (video: VideoListItem) => void;
454
+ onVideoData?: (video: VideoData) => void;
464
455
  onEmptyPlaylists?: () => void;
465
456
  onError?: (error: Error) => void;
466
457
  onPlay?: () => void;
@@ -498,7 +489,7 @@ interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
498
489
  order?: CreativeWorksSortDirection;
499
490
  events?: {
500
491
  onCreativeWorkData?: (creativeWork: CreativeWorkData) => void;
501
- onVideoData?: (video: VideoListItem) => void;
492
+ onVideoData?: (video: VideoData) => void;
502
493
  onEmptyPlaylists?: () => void;
503
494
  onError?: (error: Error) => void;
504
495
  onPlay?: () => void;
@@ -551,4 +542,4 @@ interface BigPlayIconProps {
551
542
  }
552
543
  declare const BigPlayIcon: React.FC<BigPlayIconProps>;
553
544
 
554
- export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
545
+ export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoProps, queryClient };
package/dist/index.js CHANGED
@@ -1150,6 +1150,32 @@ var import_shaka_player4 = __toESM(require("shaka-player/dist/shaka-player.ui"))
1150
1150
  // src/hooks/useShakePlayer.ts
1151
1151
  var import_react = require("react");
1152
1152
  var import_shaka_player = __toESM(require("shaka-player/dist/shaka-player.ui"));
1153
+
1154
+ // src/utils/devices.ts
1155
+ var isAppleDevice = () => {
1156
+ if (typeof navigator === "undefined") return false;
1157
+ const ua = navigator.userAgent || "";
1158
+ const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
1159
+ const isSafari = /Safari/.test(ua) && !/Chrome|CriOS|FxiOS|Edg/.test(ua);
1160
+ const isMacSafari = /Macintosh/.test(ua) && isSafari;
1161
+ return isIOS || isMacSafari;
1162
+ };
1163
+ var isPlayReadySupported = () => {
1164
+ if (typeof navigator === "undefined" || typeof window === "undefined") {
1165
+ return false;
1166
+ }
1167
+ if (!navigator.requestMediaKeySystemAccess) {
1168
+ return false;
1169
+ }
1170
+ const userAgent = navigator.userAgent || "";
1171
+ const isWindows = /Windows/.test(userAgent);
1172
+ const isXbox = /Xbox/.test(userAgent);
1173
+ const isEdge = /Edg/.test(userAgent);
1174
+ const isIE = /Trident|MSIE/.test(userAgent);
1175
+ return isWindows || isXbox || isEdge || isIE;
1176
+ };
1177
+
1178
+ // src/hooks/useShakePlayer.ts
1153
1179
  var useShakePlayer = ({
1154
1180
  src,
1155
1181
  shakaConfig,
@@ -1170,69 +1196,7 @@ var useShakePlayer = ({
1170
1196
  if (shakaConfig) {
1171
1197
  player.configure(shakaConfig);
1172
1198
  }
1173
- const isPlaylistObject = typeof src === "object" && src !== null && src.drm;
1174
- const manifestUrl = isPlaylistObject ? src.url : src;
1175
- const drmData = isPlaylistObject ? src.drm : null;
1176
- if (drmData && drmData.token) {
1177
- const isAppleDevice2 = () => {
1178
- if (typeof navigator === "undefined") return false;
1179
- const ua = navigator.userAgent || "";
1180
- const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
1181
- const isSafari = /Safari/.test(ua) && !/Chrome|CriOS|FxiOS|Edg/.test(ua);
1182
- const isMacSafari = /Macintosh/.test(ua) && isSafari;
1183
- return isIOS || isMacSafari;
1184
- };
1185
- const useFairPlay = isAppleDevice2();
1186
- const drmConfig2 = {
1187
- servers: {},
1188
- advanced: {}
1189
- };
1190
- if (useFairPlay && drmData.fairplay?.license_url) {
1191
- drmConfig2.servers["com.apple.fps"] = drmData.fairplay.license_url;
1192
- } else if (drmData.widevine?.license_url) {
1193
- drmConfig2.servers["com.widevine.alpha"] = drmData.widevine.license_url;
1194
- }
1195
- if (useFairPlay && drmData.fairplay?.certificate_url) {
1196
- try {
1197
- const req = await fetch(drmData.fairplay.certificate_url);
1198
- const cert = await req.arrayBuffer();
1199
- drmConfig2.advanced["com.apple.fps"] = {
1200
- serverCertificate: new Uint8Array(cert)
1201
- };
1202
- } catch (e) {
1203
- console.warn("Failed to fetch FairPlay certificate:", e);
1204
- }
1205
- }
1206
- if (Object.keys(drmConfig2.servers).length > 0) {
1207
- player.configure({ drm: drmConfig2 });
1208
- }
1209
- const netEngine = player.getNetworkingEngine();
1210
- if (netEngine) {
1211
- netEngine.registerRequestFilter((type, request) => {
1212
- if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
1213
- request.headers["x-dt-custom-data"] = drmData.token;
1214
- }
1215
- });
1216
- netEngine.registerResponseFilter((type, response) => {
1217
- if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
1218
- const ks = player.keySystem && player.keySystem();
1219
- if (ks === "com.apple.fps") {
1220
- const responseText = import_shaka_player.default.util.StringUtils.fromUTF8(response.data);
1221
- response.data = import_shaka_player.default.util.Uint8ArrayUtils.fromBase64(responseText).buffer;
1222
- }
1223
- }
1224
- });
1225
- }
1226
- }
1227
- if (drmConfig) {
1228
- if (drmConfig.clearKeys) {
1229
- player.configure({ "drm.clearKeys": drmConfig.clearKeys });
1230
- }
1231
- if (drmConfig.servers) {
1232
- player.configure({ "drm.servers": drmConfig.servers });
1233
- }
1234
- }
1235
- player.addEventListener("error", (event) => {
1199
+ player?.addEventListener("error", (event) => {
1236
1200
  const error = event.detail;
1237
1201
  if (error?.code === 7e3) {
1238
1202
  return;
@@ -1240,7 +1204,6 @@ var useShakePlayer = ({
1240
1204
  console.error("Shaka Player Error:", error);
1241
1205
  onError?.(new Error(`Shaka Player Error: ${error.message || "Unknown error"}`));
1242
1206
  });
1243
- await player.load(manifestUrl);
1244
1207
  onPlayerReady?.(player);
1245
1208
  return player;
1246
1209
  } catch (error) {
@@ -1252,6 +1215,60 @@ var useShakePlayer = ({
1252
1215
  throw error;
1253
1216
  }
1254
1217
  }, [shakaConfig, drmConfig, src, onError, onPlayerReady]);
1218
+ const loadSource = (0, import_react.useCallback)(async () => {
1219
+ const player = playerRef.current;
1220
+ if (!player) return;
1221
+ let manifestUrl = src.url;
1222
+ const isDRM = Boolean(src.drm);
1223
+ let cert = null;
1224
+ if (isDRM) {
1225
+ const isPlayReady = isPlayReadySupported();
1226
+ const isFairPlay = isAppleDevice();
1227
+ if (isFairPlay && src.drm.fairplay?.certificate_url) {
1228
+ const req = await fetch(src.drm.fairplay.certificate_url);
1229
+ cert = await req.arrayBuffer();
1230
+ manifestUrl = src.drm.fairplay.playlist_url;
1231
+ } else if (isPlayReady && src.drm.playready?.license_url) {
1232
+ manifestUrl = src.drm.playready.playlist_url;
1233
+ } else {
1234
+ manifestUrl = src.drm?.widevine?.playlist_url || "";
1235
+ }
1236
+ player.configure({
1237
+ drm: {
1238
+ servers: {
1239
+ "com.widevine.alpha": src.drm.widevine?.license_url,
1240
+ "com.microsoft.playready": src.drm.playready?.license_url,
1241
+ "com.apple.fps": src.drm.fairplay?.license_url
1242
+ },
1243
+ ...cert && {
1244
+ advanced: {
1245
+ "com.apple.fps": {
1246
+ serverCertificate: new Uint8Array(cert)
1247
+ }
1248
+ }
1249
+ }
1250
+ }
1251
+ });
1252
+ const netEngine = player.getNetworkingEngine();
1253
+ if (netEngine) {
1254
+ netEngine.registerRequestFilter((type, request) => {
1255
+ if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
1256
+ request.headers["x-dt-custom-data"] = src.drm.token;
1257
+ }
1258
+ });
1259
+ netEngine.registerResponseFilter((type, response) => {
1260
+ if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
1261
+ const ks = player.keySystem && player.keySystem();
1262
+ if (ks === "com.apple.fps") {
1263
+ const responseText = import_shaka_player.default.util.StringUtils.fromUTF8(response.data);
1264
+ response.data = import_shaka_player.default.util.Uint8ArrayUtils.fromBase64(responseText).buffer;
1265
+ }
1266
+ }
1267
+ });
1268
+ }
1269
+ }
1270
+ await player.load(manifestUrl);
1271
+ }, [src]);
1255
1272
  const destroyPlayer = (0, import_react.useCallback)(async () => {
1256
1273
  if (playerRef.current) {
1257
1274
  try {
@@ -1266,6 +1283,7 @@ var useShakePlayer = ({
1266
1283
  return {
1267
1284
  playerRef,
1268
1285
  initializePlayer,
1286
+ loadSource,
1269
1287
  destroyPlayer
1270
1288
  };
1271
1289
  };
@@ -1390,7 +1408,7 @@ var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
1390
1408
  var import_shaka_player2 = __toESM(require("shaka-player/dist/shaka-player.ui"));
1391
1409
 
1392
1410
  // package.json
1393
- var version = "1.0.1-rc.25";
1411
+ var version = "1.0.1-rc.27";
1394
1412
 
1395
1413
  // src/hooks/useMuxAnalytics.ts
1396
1414
  var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
@@ -3295,7 +3313,7 @@ var Player = (0, import_react12.forwardRef)(
3295
3313
  const containerRef = (0, import_react12.useRef)(null);
3296
3314
  const adContainerRef = (0, import_react12.useRef)(null);
3297
3315
  (0, import_react12.useImperativeHandle)(ref, () => videoRef.current, []);
3298
- const { playerRef, initializePlayer, destroyPlayer } = useShakePlayer({
3316
+ const { playerRef, initializePlayer, loadSource, destroyPlayer } = useShakePlayer({
3299
3317
  src,
3300
3318
  shakaConfig,
3301
3319
  drmConfig,
@@ -3403,11 +3421,12 @@ var Player = (0, import_react12.forwardRef)(
3403
3421
  const initialize = async () => {
3404
3422
  try {
3405
3423
  await initializePlayer(video);
3424
+ initializeMux();
3425
+ await loadSource();
3406
3426
  setupEventListeners();
3407
3427
  const cleanupQuality = setupQualityTracking();
3408
3428
  configureQuality();
3409
3429
  await initializeUI();
3410
- initializeMux();
3411
3430
  initializeAds();
3412
3431
  initializeChromecast();
3413
3432
  } catch (error) {
@@ -4065,7 +4084,7 @@ var Video = ({
4065
4084
  Player,
4066
4085
  {
4067
4086
  ...props,
4068
- src: hlsUrl,
4087
+ src: activePlaylist,
4069
4088
  className: (0, import_tailwind_merge3.twMerge)("video-player-container", className),
4070
4089
  events,
4071
4090
  containerClassName: "w-full h-full",
@@ -4079,14 +4098,6 @@ var import_react15 = require("react");
4079
4098
  var import_tailwind_merge4 = require("tailwind-merge");
4080
4099
  var import_react_query2 = require("@tanstack/react-query");
4081
4100
  var import_jsx_runtime10 = require("react/jsx-runtime");
4082
- var isAppleDevice = () => {
4083
- if (typeof navigator === "undefined") return false;
4084
- const ua = navigator.userAgent || navigator.vendor || "";
4085
- const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
4086
- const isSafari = /Safari/.test(ua) && !/Chrome|CriOS|FxiOS|Edg/.test(ua);
4087
- const isMacSafari = /Macintosh/.test(ua) && isSafari;
4088
- return isIOS || isMacSafari;
4089
- };
4090
4101
  var Event = ({
4091
4102
  publicKey,
4092
4103
  eventId,
@@ -4119,7 +4130,6 @@ var Event = ({
4119
4130
  const [activePlaylist, setActivePlaylist] = (0, import_react15.useState)();
4120
4131
  const [activeVideoId, setActiveVideoId] = (0, import_react15.useState)();
4121
4132
  const videoIds = eventData?.videoIds ?? [];
4122
- const [isDRM, setIsDRM] = (0, import_react15.useState)(false);
4123
4133
  const {
4124
4134
  data: videosData,
4125
4135
  isLoading: videosIsLoading,
@@ -4146,34 +4156,9 @@ var Event = ({
4146
4156
  for (const video of videosWithPlaylists) {
4147
4157
  const hlsPlaylist = findHLSPlaylist(video);
4148
4158
  if (hlsPlaylist?.url) {
4149
- const matchedPlaylist = video.playlists?.find((p) => p.url === hlsPlaylist.url);
4150
- const drm = matchedPlaylist?.drm;
4151
- const hasDrm = Boolean(drm?.token);
4152
- let selectedPlaylist;
4153
- if (hasDrm) {
4154
- const useFairPlay = isAppleDevice();
4155
- if (useFairPlay && drm?.fairplay?.playlist_url && drm?.fairplay?.license_url) {
4156
- selectedPlaylist = {
4157
- url: drm.fairplay.playlist_url,
4158
- format: matchedPlaylist?.format || "HLS",
4159
- drm
4160
- };
4161
- } else if (drm?.widevine?.playlist_url && drm?.widevine?.license_url) {
4162
- selectedPlaylist = {
4163
- url: drm.widevine.playlist_url,
4164
- format: matchedPlaylist?.format || "HLS",
4165
- drm
4166
- };
4167
- } else {
4168
- selectedPlaylist = matchedPlaylist;
4169
- }
4170
- } else {
4171
- selectedPlaylist = hlsPlaylist.url;
4172
- }
4173
- setActivePlaylist(selectedPlaylist);
4159
+ setActivePlaylist(hlsPlaylist);
4174
4160
  setActiveVideoId(video.id);
4175
4161
  hlsPlaylistFound = true;
4176
- setIsDRM(Boolean(hasDrm));
4177
4162
  break;
4178
4163
  }
4179
4164
  }
@@ -4197,11 +4182,6 @@ var Event = ({
4197
4182
  events.onEventData(eventData);
4198
4183
  }
4199
4184
  }, [eventData, events]);
4200
- (0, import_react15.useEffect)(() => {
4201
- if (isDRM) {
4202
- console.log("DRM is enabled");
4203
- }
4204
- }, [isDRM]);
4205
4185
  (0, import_react15.useEffect)(() => {
4206
4186
  if (events?.onVideoData && activeVideoId && videosData) {
4207
4187
  const activeVideo = videosData.find((video) => video.id === activeVideoId);
@@ -4518,7 +4498,7 @@ var CreativeWork = ({
4518
4498
  for (const video of videosWithPlaylists) {
4519
4499
  const hlsPlaylist = findHLSPlaylist(video);
4520
4500
  if (hlsPlaylist?.url) {
4521
- setActivePlaylist(hlsPlaylist.url);
4501
+ setActivePlaylist(hlsPlaylist);
4522
4502
  setActiveVideoId(video.id);
4523
4503
  hlsPlaylistFound = true;
4524
4504
  break;