@mottosports/motto-video-player 1.0.1-rc.24 → 1.0.1-rc.26
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 +70 -79
- package/dist/index.d.ts +70 -79
- package/dist/index.js +61 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1109,6 +1109,32 @@ import shaka3 from "shaka-player/dist/shaka-player.ui";
|
|
|
1109
1109
|
// src/hooks/useShakePlayer.ts
|
|
1110
1110
|
import { useRef, useCallback } from "react";
|
|
1111
1111
|
import shaka from "shaka-player/dist/shaka-player.ui";
|
|
1112
|
+
|
|
1113
|
+
// src/utils/devices.ts
|
|
1114
|
+
var isAppleDevice = () => {
|
|
1115
|
+
if (typeof navigator === "undefined") return false;
|
|
1116
|
+
const ua = navigator.userAgent || "";
|
|
1117
|
+
const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
1118
|
+
const isSafari = /Safari/.test(ua) && !/Chrome|CriOS|FxiOS|Edg/.test(ua);
|
|
1119
|
+
const isMacSafari = /Macintosh/.test(ua) && isSafari;
|
|
1120
|
+
return isIOS || isMacSafari;
|
|
1121
|
+
};
|
|
1122
|
+
var isPlayReadySupported = () => {
|
|
1123
|
+
if (typeof navigator === "undefined" || typeof window === "undefined") {
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
if (!navigator.requestMediaKeySystemAccess) {
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
const userAgent = navigator.userAgent || "";
|
|
1130
|
+
const isWindows = /Windows/.test(userAgent);
|
|
1131
|
+
const isXbox = /Xbox/.test(userAgent);
|
|
1132
|
+
const isEdge = /Edg/.test(userAgent);
|
|
1133
|
+
const isIE = /Trident|MSIE/.test(userAgent);
|
|
1134
|
+
return isWindows || isXbox || isEdge || isIE;
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
// src/hooks/useShakePlayer.ts
|
|
1112
1138
|
var useShakePlayer = ({
|
|
1113
1139
|
src,
|
|
1114
1140
|
shakaConfig,
|
|
@@ -1129,47 +1155,42 @@ var useShakePlayer = ({
|
|
|
1129
1155
|
if (shakaConfig) {
|
|
1130
1156
|
player.configure(shakaConfig);
|
|
1131
1157
|
}
|
|
1132
|
-
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
if (
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
servers: {},
|
|
1147
|
-
advanced: {}
|
|
1148
|
-
};
|
|
1149
|
-
if (useFairPlay && drmData.fairplay?.license_url) {
|
|
1150
|
-
drmConfig2.servers["com.apple.fps"] = drmData.fairplay.license_url;
|
|
1151
|
-
} else if (drmData.widevine?.license_url) {
|
|
1152
|
-
drmConfig2.servers["com.widevine.alpha"] = drmData.widevine.license_url;
|
|
1158
|
+
let manifestUrl = src.url;
|
|
1159
|
+
const isDRM = Boolean(src.drm);
|
|
1160
|
+
let cert = null;
|
|
1161
|
+
if (isDRM) {
|
|
1162
|
+
const isPlayReady = isPlayReadySupported();
|
|
1163
|
+
const isFairPlay = isAppleDevice();
|
|
1164
|
+
if (isAppleDevice() && src.drm.fairplay?.certificate_url) {
|
|
1165
|
+
const req = await fetch(src.drm.fairplay.certificate_url);
|
|
1166
|
+
cert = await req.arrayBuffer();
|
|
1167
|
+
manifestUrl = src.drm.fairplay.playlist_url;
|
|
1168
|
+
} else if (isPlayReady && src.drm.playready?.license_url) {
|
|
1169
|
+
manifestUrl = src.drm.playready.playlist_url;
|
|
1170
|
+
} else {
|
|
1171
|
+
manifestUrl = src.drm?.widevine?.playlist_url || "";
|
|
1153
1172
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1173
|
+
player.configure({
|
|
1174
|
+
drm: {
|
|
1175
|
+
servers: {
|
|
1176
|
+
"com.widevine.alpha": src.drm.widevine?.license_url,
|
|
1177
|
+
"com.microsoft.playready": src.drm.playready?.license_url,
|
|
1178
|
+
"com.apple.fps": src.drm.fairplay?.license_url
|
|
1179
|
+
},
|
|
1180
|
+
...cert && {
|
|
1181
|
+
advanced: {
|
|
1182
|
+
"com.apple.fps": {
|
|
1183
|
+
serverCertificate: new Uint8Array(cert)
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1163
1187
|
}
|
|
1164
|
-
}
|
|
1165
|
-
if (Object.keys(drmConfig2.servers).length > 0) {
|
|
1166
|
-
player.configure({ drm: drmConfig2 });
|
|
1167
|
-
}
|
|
1188
|
+
});
|
|
1168
1189
|
const netEngine = player.getNetworkingEngine();
|
|
1169
1190
|
if (netEngine) {
|
|
1170
1191
|
netEngine.registerRequestFilter((type, request) => {
|
|
1171
1192
|
if (type === shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1172
|
-
request.headers["x-dt-custom-data"] =
|
|
1193
|
+
request.headers["x-dt-custom-data"] = src.drm.token;
|
|
1173
1194
|
}
|
|
1174
1195
|
});
|
|
1175
1196
|
netEngine.registerResponseFilter((type, response) => {
|
|
@@ -1183,15 +1204,7 @@ var useShakePlayer = ({
|
|
|
1183
1204
|
});
|
|
1184
1205
|
}
|
|
1185
1206
|
}
|
|
1186
|
-
|
|
1187
|
-
if (drmConfig.clearKeys) {
|
|
1188
|
-
player.configure({ "drm.clearKeys": drmConfig.clearKeys });
|
|
1189
|
-
}
|
|
1190
|
-
if (drmConfig.servers) {
|
|
1191
|
-
player.configure({ "drm.servers": drmConfig.servers });
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
player.addEventListener("error", (event) => {
|
|
1207
|
+
player?.addEventListener("error", (event) => {
|
|
1195
1208
|
const error = event.detail;
|
|
1196
1209
|
if (error?.code === 7e3) {
|
|
1197
1210
|
return;
|
|
@@ -1349,7 +1362,7 @@ import initShakaPlayerMux from "@mux/mux-data-shakaplayer";
|
|
|
1349
1362
|
import shaka2 from "shaka-player/dist/shaka-player.ui";
|
|
1350
1363
|
|
|
1351
1364
|
// package.json
|
|
1352
|
-
var version = "1.0.1-rc.
|
|
1365
|
+
var version = "1.0.1-rc.26";
|
|
1353
1366
|
|
|
1354
1367
|
// src/hooks/useMuxAnalytics.ts
|
|
1355
1368
|
var useMuxAnalytics = (playerRef, muxConfig, onMuxReady, onMuxDataUpdate) => {
|
|
@@ -4024,7 +4037,7 @@ var Video = ({
|
|
|
4024
4037
|
Player,
|
|
4025
4038
|
{
|
|
4026
4039
|
...props,
|
|
4027
|
-
src:
|
|
4040
|
+
src: activePlaylist,
|
|
4028
4041
|
className: twMerge3("video-player-container", className),
|
|
4029
4042
|
events,
|
|
4030
4043
|
containerClassName: "w-full h-full",
|
|
@@ -4038,14 +4051,6 @@ import { useCallback as useCallback8, useEffect as useEffect8, useState as useSt
|
|
|
4038
4051
|
import { twMerge as twMerge4 } from "tailwind-merge";
|
|
4039
4052
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
4040
4053
|
import { Fragment, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4041
|
-
var isAppleDevice = () => {
|
|
4042
|
-
if (typeof navigator === "undefined") return false;
|
|
4043
|
-
const ua = navigator.userAgent || navigator.vendor || "";
|
|
4044
|
-
const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
4045
|
-
const isSafari = /Safari/.test(ua) && !/Chrome|CriOS|FxiOS|Edg/.test(ua);
|
|
4046
|
-
const isMacSafari = /Macintosh/.test(ua) && isSafari;
|
|
4047
|
-
return isIOS || isMacSafari;
|
|
4048
|
-
};
|
|
4049
4054
|
var Event = ({
|
|
4050
4055
|
publicKey,
|
|
4051
4056
|
eventId,
|
|
@@ -4078,7 +4083,6 @@ var Event = ({
|
|
|
4078
4083
|
const [activePlaylist, setActivePlaylist] = useState4();
|
|
4079
4084
|
const [activeVideoId, setActiveVideoId] = useState4();
|
|
4080
4085
|
const videoIds = eventData?.videoIds ?? [];
|
|
4081
|
-
const [isDRM, setIsDRM] = useState4(false);
|
|
4082
4086
|
const {
|
|
4083
4087
|
data: videosData,
|
|
4084
4088
|
isLoading: videosIsLoading,
|
|
@@ -4105,34 +4109,9 @@ var Event = ({
|
|
|
4105
4109
|
for (const video of videosWithPlaylists) {
|
|
4106
4110
|
const hlsPlaylist = findHLSPlaylist(video);
|
|
4107
4111
|
if (hlsPlaylist?.url) {
|
|
4108
|
-
|
|
4109
|
-
const drm = matchedPlaylist?.dvr;
|
|
4110
|
-
const hasDrm = Boolean(drm?.token);
|
|
4111
|
-
let selectedPlaylist;
|
|
4112
|
-
if (hasDrm) {
|
|
4113
|
-
const useFairPlay = isAppleDevice();
|
|
4114
|
-
if (useFairPlay && drm?.fairplay?.playlist_url && drm?.fairplay?.license_url) {
|
|
4115
|
-
selectedPlaylist = {
|
|
4116
|
-
url: drm.fairplay.playlist_url,
|
|
4117
|
-
format: matchedPlaylist?.format || "HLS",
|
|
4118
|
-
dvr: drm
|
|
4119
|
-
};
|
|
4120
|
-
} else if (drm?.widevine?.playlist_url && drm?.widevine?.license_url) {
|
|
4121
|
-
selectedPlaylist = {
|
|
4122
|
-
url: drm.widevine.playlist_url,
|
|
4123
|
-
format: matchedPlaylist?.format || "HLS",
|
|
4124
|
-
dvr: drm
|
|
4125
|
-
};
|
|
4126
|
-
} else {
|
|
4127
|
-
selectedPlaylist = matchedPlaylist;
|
|
4128
|
-
}
|
|
4129
|
-
} else {
|
|
4130
|
-
selectedPlaylist = hlsPlaylist.url;
|
|
4131
|
-
}
|
|
4132
|
-
setActivePlaylist(selectedPlaylist);
|
|
4112
|
+
setActivePlaylist(hlsPlaylist);
|
|
4133
4113
|
setActiveVideoId(video.id);
|
|
4134
4114
|
hlsPlaylistFound = true;
|
|
4135
|
-
setIsDRM(Boolean(hasDrm));
|
|
4136
4115
|
break;
|
|
4137
4116
|
}
|
|
4138
4117
|
}
|
|
@@ -4156,11 +4135,6 @@ var Event = ({
|
|
|
4156
4135
|
events.onEventData(eventData);
|
|
4157
4136
|
}
|
|
4158
4137
|
}, [eventData, events]);
|
|
4159
|
-
useEffect8(() => {
|
|
4160
|
-
if (isDRM) {
|
|
4161
|
-
console.log("DRM is enabled");
|
|
4162
|
-
}
|
|
4163
|
-
}, [isDRM]);
|
|
4164
4138
|
useEffect8(() => {
|
|
4165
4139
|
if (events?.onVideoData && activeVideoId && videosData) {
|
|
4166
4140
|
const activeVideo = videosData.find((video) => video.id === activeVideoId);
|
|
@@ -4477,7 +4451,7 @@ var CreativeWork = ({
|
|
|
4477
4451
|
for (const video of videosWithPlaylists) {
|
|
4478
4452
|
const hlsPlaylist = findHLSPlaylist(video);
|
|
4479
4453
|
if (hlsPlaylist?.url) {
|
|
4480
|
-
setActivePlaylist(hlsPlaylist
|
|
4454
|
+
setActivePlaylist(hlsPlaylist);
|
|
4481
4455
|
setActiveVideoId(video.id);
|
|
4482
4456
|
hlsPlaylistFound = true;
|
|
4483
4457
|
break;
|