@streamplace/components 0.7.0 → 0.7.2
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/components/chat/chat-box.js +46 -43
- package/dist/components/chat/chat-message.js +36 -33
- package/dist/components/chat/chat.js +31 -27
- package/dist/components/chat/mention-suggestions.js +16 -13
- package/dist/components/chat/mod-view.js +20 -17
- package/dist/components/mobile-player/fullscreen.js +21 -17
- package/dist/components/mobile-player/fullscreen.native.js +39 -35
- package/dist/components/mobile-player/player.js +38 -32
- package/dist/components/mobile-player/props.js +2 -1
- package/dist/components/mobile-player/shared.js +16 -13
- package/dist/components/mobile-player/ui/countdown.js +23 -19
- package/dist/components/mobile-player/ui/index.js +9 -5
- package/dist/components/mobile-player/ui/input.js +16 -12
- package/dist/components/mobile-player/ui/metrics.js +20 -16
- package/dist/components/mobile-player/ui/streamer-context-menu.js +6 -3
- package/dist/components/mobile-player/ui/viewer-context-menu.js +19 -16
- package/dist/components/mobile-player/ui/viewers.js +23 -0
- package/dist/components/mobile-player/use-webrtc.js +29 -24
- package/dist/components/mobile-player/video.js +109 -99
- package/dist/components/mobile-player/video.native.js +108 -84
- package/dist/components/mobile-player/webrtc-diagnostics.js +9 -5
- package/dist/components/mobile-player/webrtc-primitives.js +8 -6
- package/dist/components/mobile-player/webrtc-primitives.native.js +8 -1
- package/dist/components/ui/button.js +26 -23
- package/dist/components/ui/dialog.js +43 -40
- package/dist/components/ui/dropdown.js +121 -116
- package/dist/components/ui/icons.js +8 -5
- package/dist/components/ui/index.js +27 -19
- package/dist/components/ui/input.js +31 -28
- package/dist/components/ui/loader.js +9 -6
- package/dist/components/ui/primitives/button.js +33 -29
- package/dist/components/ui/primitives/input.js +44 -40
- package/dist/components/ui/primitives/modal.js +45 -41
- package/dist/components/ui/primitives/text.js +35 -29
- package/dist/components/ui/resizeable.js +54 -43
- package/dist/components/ui/text.js +50 -48
- package/dist/components/ui/textarea.js +13 -11
- package/dist/components/ui/toast.js +26 -23
- package/dist/components/ui/view.js +41 -39
- package/dist/hooks/index.js +12 -8
- package/dist/hooks/useAvatars.js +11 -8
- package/dist/hooks/useCameraToggle.js +7 -4
- package/dist/hooks/useKeyboard.js +13 -10
- package/dist/hooks/useKeyboardSlide.js +8 -5
- package/dist/hooks/useLivestreamInfo.js +17 -14
- package/dist/hooks/useOuterAndInnerDimensions.js +9 -6
- package/dist/hooks/usePlayerDimensions.js +9 -6
- package/dist/hooks/useSegmentDimensions.js +17 -0
- package/dist/hooks/useSegmentTiming.js +13 -10
- package/dist/index.js +24 -15
- package/dist/lib/facet.js +5 -1
- package/dist/lib/theme/atoms.js +153 -148
- package/dist/lib/theme/atoms.types.js +2 -1
- package/dist/lib/theme/index.js +31 -5
- package/dist/lib/theme/theme.js +91 -83
- package/dist/lib/theme/tokens.js +15 -12
- package/dist/lib/utils.js +22 -11
- package/dist/livestream-provider/index.js +19 -14
- package/dist/livestream-provider/websocket.js +14 -10
- package/dist/livestream-store/chat.js +26 -19
- package/dist/livestream-store/context.js +5 -2
- package/dist/livestream-store/index.js +7 -4
- package/dist/livestream-store/livestream-state.js +2 -1
- package/dist/livestream-store/livestream-store.js +31 -18
- package/dist/livestream-store/stream-key.js +22 -18
- package/dist/livestream-store/websocket-consumer.js +18 -14
- package/dist/player-store/context.js +5 -2
- package/dist/player-store/index.js +8 -5
- package/dist/player-store/player-provider.js +20 -15
- package/dist/player-store/player-state.js +9 -6
- package/dist/player-store/player-store.js +32 -21
- package/dist/player-store/single-player-provider.js +35 -23
- package/dist/streamplace-provider/context.js +5 -2
- package/dist/streamplace-provider/index.js +14 -10
- package/dist/streamplace-provider/poller.js +20 -17
- package/dist/streamplace-store/block.js +6 -3
- package/dist/streamplace-store/index.js +6 -3
- package/dist/streamplace-store/stream.js +14 -10
- package/dist/streamplace-store/streamplace-store.js +23 -13
- package/dist/streamplace-store/user.js +19 -14
- package/dist/streamplace-store/xrpc.js +10 -7
- package/node-compile-cache/v22.15.0-x64-92db9086-0/37be0eec +0 -0
- package/node-compile-cache/v22.15.0-x64-92db9086-0/56540125 +0 -0
- package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/67b1eb60 +0 -0
- package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/7c275f90 +0 -0
- package/package.json +6 -7
- package/src/components/mobile-player/ui/index.ts +1 -0
- package/src/components/mobile-player/ui/viewer-context-menu.tsx +5 -4
- package/src/components/mobile-player/ui/viewers.tsx +32 -0
- package/src/components/mobile-player/video.native.tsx +50 -5
- package/src/components/ui/resizeable.tsx +15 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useSegmentDimensions.tsx +18 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/56540125 +0 -0
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = useWebRTC;
|
|
4
|
+
exports.negotiateConnectionWithClientOffer = negotiateConnectionWithClientOffer;
|
|
5
|
+
exports.useWebRTCIngest = useWebRTCIngest;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
const webrtc_primitives_1 = require("./webrtc-primitives");
|
|
9
|
+
function useWebRTC(endpoint) {
|
|
10
|
+
const [mediaStream, setMediaStream] = (0, react_1.useState)(null);
|
|
11
|
+
const [stuck, setStuck] = (0, react_1.useState)(false);
|
|
12
|
+
const lastChange = (0, react_1.useRef)(0);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const peerConnection = new webrtc_primitives_1.RTCPeerConnection({
|
|
10
15
|
bundlePolicy: "max-bundle",
|
|
11
16
|
});
|
|
12
17
|
peerConnection.addTransceiver("video", {
|
|
@@ -80,7 +85,7 @@ export default function useWebRTC(endpoint) {
|
|
|
80
85
|
* https://developer.mozilla.org/en-US/docs/Glossary/SDP
|
|
81
86
|
* https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html#name-protocol-operation
|
|
82
87
|
*/
|
|
83
|
-
|
|
88
|
+
async function negotiateConnectionWithClientOffer(peerConnection, endpoint, bearerToken) {
|
|
84
89
|
/** https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer */
|
|
85
90
|
const offer = await peerConnection.createOffer({
|
|
86
91
|
offerToReceiveAudio: true,
|
|
@@ -109,7 +114,7 @@ export async function negotiateConnectionWithClientOffer(peerConnection, endpoin
|
|
|
109
114
|
if (peerConnection.connectionState === "closed") {
|
|
110
115
|
return;
|
|
111
116
|
}
|
|
112
|
-
await peerConnection.setRemoteDescription(new RTCSessionDescription({ type: "answer", sdp: answerSDP }));
|
|
117
|
+
await peerConnection.setRemoteDescription(new webrtc_primitives_1.RTCSessionDescription({ type: "answer", sdp: answerSDP }));
|
|
113
118
|
return response.headers.get("Location");
|
|
114
119
|
}
|
|
115
120
|
else if (response.status === 405) {
|
|
@@ -162,25 +167,25 @@ async function waitToCompleteICEGathering(peerConnection) {
|
|
|
162
167
|
});
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
|
-
|
|
166
|
-
const [mediaStream, setMediaStream] = useState(null);
|
|
167
|
-
const ingestConnectionState = usePlayerStore((x) => x.ingestConnectionState);
|
|
168
|
-
const setIngestConnectionState = usePlayerStore((x) => x.setIngestConnectionState);
|
|
169
|
-
const storedKey = useStreamKey();
|
|
170
|
-
const [peerConnection, setPeerConnection] = useState(null);
|
|
171
|
-
const videoTransceiver = useRef(null);
|
|
172
|
-
const audioTransceiver = useRef(null);
|
|
173
|
-
const [retryTime, setRetryTime] = useState(0);
|
|
174
|
-
const ingestLive = usePlayerStore((x) => x.ingestLive);
|
|
170
|
+
function useWebRTCIngest({ endpoint, }) {
|
|
171
|
+
const [mediaStream, setMediaStream] = (0, react_1.useState)(null);
|
|
172
|
+
const ingestConnectionState = (0, __1.usePlayerStore)((x) => x.ingestConnectionState);
|
|
173
|
+
const setIngestConnectionState = (0, __1.usePlayerStore)((x) => x.setIngestConnectionState);
|
|
174
|
+
const storedKey = (0, __1.useStreamKey)();
|
|
175
|
+
const [peerConnection, setPeerConnection] = (0, react_1.useState)(null);
|
|
176
|
+
const videoTransceiver = (0, react_1.useRef)(null);
|
|
177
|
+
const audioTransceiver = (0, react_1.useRef)(null);
|
|
178
|
+
const [retryTime, setRetryTime] = (0, react_1.useState)(0);
|
|
179
|
+
const ingestLive = (0, __1.usePlayerStore)((x) => x.ingestLive);
|
|
175
180
|
// "Outer loop": when we need a new peer connection, this sets that up
|
|
176
|
-
useEffect(() => {
|
|
181
|
+
(0, react_1.useEffect)(() => {
|
|
177
182
|
if (!storedKey) {
|
|
178
183
|
return;
|
|
179
184
|
}
|
|
180
185
|
if (!ingestLive) {
|
|
181
186
|
return;
|
|
182
187
|
}
|
|
183
|
-
const peerConnection = new RTCPeerConnection({
|
|
188
|
+
const peerConnection = new webrtc_primitives_1.RTCPeerConnection({
|
|
184
189
|
bundlePolicy: "max-bundle",
|
|
185
190
|
});
|
|
186
191
|
videoTransceiver.current = peerConnection.addTransceiver("video", {
|
|
@@ -208,7 +213,7 @@ export function useWebRTCIngest({ endpoint, }) {
|
|
|
208
213
|
};
|
|
209
214
|
}, [endpoint, storedKey.streamKey?.privateKey, retryTime, ingestLive]);
|
|
210
215
|
// "Inner loop": when our tracks change, we update the transceivers
|
|
211
|
-
useEffect(() => {
|
|
216
|
+
(0, react_1.useEffect)(() => {
|
|
212
217
|
if (!mediaStream) {
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = WebVideo;
|
|
4
|
+
exports.ProgressiveMP4Player = ProgressiveMP4Player;
|
|
5
|
+
exports.ProgressiveWebMPlayer = ProgressiveWebMPlayer;
|
|
6
|
+
exports.HLSPlayer = HLSPlayer;
|
|
7
|
+
exports.WebRTCPlayer = WebRTCPlayer;
|
|
8
|
+
exports.WebRTCPlayerInner = WebRTCPlayerInner;
|
|
9
|
+
exports.WebcamIngestPlayer = WebcamIngestPlayer;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
const hls_js_1 = tslib_1.__importDefault(require("hls.js"));
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const __1 = require("../..");
|
|
15
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
16
|
+
const index_1 = require("../ui/index");
|
|
17
|
+
const shared_1 = require("./shared");
|
|
18
|
+
const use_webrtc_1 = tslib_1.__importStar(require("./use-webrtc"));
|
|
19
|
+
const webrtc_diagnostics_1 = require("./webrtc-diagnostics");
|
|
20
|
+
const webrtc_primitives_1 = require("./webrtc-primitives");
|
|
11
21
|
function assignVideoRef(ref, instance) {
|
|
12
22
|
if (!ref)
|
|
13
23
|
return;
|
|
@@ -17,8 +27,8 @@ function assignVideoRef(ref, instance) {
|
|
|
17
27
|
ref.current = instance;
|
|
18
28
|
}
|
|
19
29
|
function useVideoDimensions(videoRef) {
|
|
20
|
-
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
|
21
|
-
useEffect(() => {
|
|
30
|
+
const [dimensions, setDimensions] = (0, react_1.useState)({ width: 0, height: 0 });
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
22
32
|
if (!videoRef.current)
|
|
23
33
|
return;
|
|
24
34
|
function updateSize() {
|
|
@@ -40,24 +50,24 @@ function useVideoDimensions(videoRef) {
|
|
|
40
50
|
}, [videoRef, videoRef.current]);
|
|
41
51
|
return dimensions;
|
|
42
52
|
}
|
|
43
|
-
|
|
44
|
-
const inProto = usePlayerStore((x) => x.protocol);
|
|
45
|
-
const isIngesting = usePlayerStore((x) => x.ingestConnectionState !== null);
|
|
46
|
-
const selectedRendition = usePlayerStore((x) => x.selectedRendition);
|
|
47
|
-
const src = usePlayerStore((x) => x.src);
|
|
48
|
-
const setPlayerWidth = usePlayerStore((x) => x.setPlayerWidth);
|
|
49
|
-
const setPlayerHeight = usePlayerStore((x) => x.setPlayerHeight);
|
|
50
|
-
const { url, protocol } = srcToUrl({ src: src, selectedRendition }, inProto);
|
|
51
|
-
const videoRef = useRef(null);
|
|
53
|
+
function WebVideo() {
|
|
54
|
+
const inProto = (0, __1.usePlayerStore)((x) => x.protocol);
|
|
55
|
+
const isIngesting = (0, __1.usePlayerStore)((x) => x.ingestConnectionState !== null);
|
|
56
|
+
const selectedRendition = (0, __1.usePlayerStore)((x) => x.selectedRendition);
|
|
57
|
+
const src = (0, __1.usePlayerStore)((x) => x.src);
|
|
58
|
+
const setPlayerWidth = (0, __1.usePlayerStore)((x) => x.setPlayerWidth);
|
|
59
|
+
const setPlayerHeight = (0, __1.usePlayerStore)((x) => x.setPlayerHeight);
|
|
60
|
+
const { url, protocol } = (0, shared_1.srcToUrl)({ src: src, selectedRendition }, inProto);
|
|
61
|
+
const videoRef = (0, react_1.useRef)(null);
|
|
52
62
|
const dimensions = useVideoDimensions(videoRef);
|
|
53
|
-
useEffect(() => {
|
|
63
|
+
(0, react_1.useEffect)(() => {
|
|
54
64
|
if (videoRef.current) {
|
|
55
65
|
setPlayerWidth(dimensions.width);
|
|
56
66
|
setPlayerHeight(dimensions.height);
|
|
57
67
|
}
|
|
58
68
|
}, [dimensions, setPlayerWidth, setPlayerHeight]);
|
|
59
69
|
const playerProps = { url, videoRef };
|
|
60
|
-
return (
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isIngesting ? ((0, jsx_runtime_1.jsx)(WebcamIngestPlayer, { ...playerProps })) : protocol === __1.PlayerProtocol.PROGRESSIVE_MP4 ? ((0, jsx_runtime_1.jsx)(ProgressiveMP4Player, { ...playerProps })) : protocol === __1.PlayerProtocol.PROGRESSIVE_WEBM ? ((0, jsx_runtime_1.jsx)(ProgressiveWebMPlayer, { ...playerProps })) : protocol === __1.PlayerProtocol.HLS ? ((0, jsx_runtime_1.jsx)(HLSPlayer, { ...playerProps })) : protocol === __1.PlayerProtocol.WEBRTC ? ((0, jsx_runtime_1.jsx)(WebRTCPlayer, { ...playerProps })) : ((() => {
|
|
61
71
|
throw new Error(`unknown playback protocol ${inProto}`);
|
|
62
72
|
})()) }));
|
|
63
73
|
}
|
|
@@ -69,18 +79,18 @@ const updateEvents = {
|
|
|
69
79
|
suspend: true,
|
|
70
80
|
mute: true,
|
|
71
81
|
};
|
|
72
|
-
const VideoElement = forwardRef((props, ref) => {
|
|
73
|
-
const x = usePlayerStore((x) => x);
|
|
74
|
-
const url = useStreamplaceStore((x) => x.url);
|
|
75
|
-
const playerEvent = usePlayerStore((x) => x.playerEvent);
|
|
76
|
-
const setMuted = usePlayerStore((x) => x.setMuted);
|
|
77
|
-
const setMuteWasForced = usePlayerStore((x) => x.setMuteWasForced);
|
|
78
|
-
const muted = usePlayerStore((x) => x.muted);
|
|
79
|
-
const ingest = usePlayerStore((x) => x.ingestConnectionState !== null);
|
|
80
|
-
const volume = usePlayerStore((x) => x.volume);
|
|
81
|
-
const setStatus = usePlayerStore((x) => x.setStatus);
|
|
82
|
-
const setUserInteraction = usePlayerStore((x) => x.setUserInteraction);
|
|
83
|
-
const setVideoRef = usePlayerStore((x) => x.setVideoRef);
|
|
82
|
+
const VideoElement = (0, react_1.forwardRef)((props, ref) => {
|
|
83
|
+
const x = (0, __1.usePlayerStore)((x) => x);
|
|
84
|
+
const url = (0, __1.useStreamplaceStore)((x) => x.url);
|
|
85
|
+
const playerEvent = (0, __1.usePlayerStore)((x) => x.playerEvent);
|
|
86
|
+
const setMuted = (0, __1.usePlayerStore)((x) => x.setMuted);
|
|
87
|
+
const setMuteWasForced = (0, __1.usePlayerStore)((x) => x.setMuteWasForced);
|
|
88
|
+
const muted = (0, __1.usePlayerStore)((x) => x.muted);
|
|
89
|
+
const ingest = (0, __1.usePlayerStore)((x) => x.ingestConnectionState !== null);
|
|
90
|
+
const volume = (0, __1.usePlayerStore)((x) => x.volume);
|
|
91
|
+
const setStatus = (0, __1.usePlayerStore)((x) => x.setStatus);
|
|
92
|
+
const setUserInteraction = (0, __1.usePlayerStore)((x) => x.setUserInteraction);
|
|
93
|
+
const setVideoRef = (0, __1.usePlayerStore)((x) => x.setVideoRef);
|
|
84
94
|
const event = (evType) => (e) => {
|
|
85
95
|
console.log(evType);
|
|
86
96
|
const now = new Date();
|
|
@@ -90,8 +100,8 @@ const VideoElement = forwardRef((props, ref) => {
|
|
|
90
100
|
console.log("Sending", evType, "status to", url);
|
|
91
101
|
playerEvent(url, now.toISOString(), evType, {});
|
|
92
102
|
};
|
|
93
|
-
const [firstAttempt, setFirstAttempt] = useState(true);
|
|
94
|
-
const localVideoRef = props.videoRef ?? useRef(null);
|
|
103
|
+
const [firstAttempt, setFirstAttempt] = (0, react_1.useState)(true);
|
|
104
|
+
const localVideoRef = props.videoRef ?? (0, react_1.useRef)(null);
|
|
95
105
|
const canPlayThrough = (e) => {
|
|
96
106
|
event("canplaythrough")(e);
|
|
97
107
|
if (firstAttempt && localVideoRef.current) {
|
|
@@ -115,18 +125,18 @@ const VideoElement = forwardRef((props, ref) => {
|
|
|
115
125
|
});
|
|
116
126
|
}
|
|
117
127
|
};
|
|
118
|
-
useEffect(() => {
|
|
128
|
+
(0, react_1.useEffect)(() => {
|
|
119
129
|
return () => {
|
|
120
|
-
setStatus(PlayerStatus.START);
|
|
130
|
+
setStatus(__1.PlayerStatus.START);
|
|
121
131
|
};
|
|
122
132
|
}, []);
|
|
123
|
-
useEffect(() => {
|
|
133
|
+
(0, react_1.useEffect)(() => {
|
|
124
134
|
if (localVideoRef.current) {
|
|
125
135
|
localVideoRef.current.volume = volume;
|
|
126
136
|
console.log("Setting volume to", volume);
|
|
127
137
|
}
|
|
128
138
|
}, [volume]);
|
|
129
|
-
useEffect(() => {
|
|
139
|
+
(0, react_1.useEffect)(() => {
|
|
130
140
|
console.log(localVideoRef.current?.width, localVideoRef.current?.height);
|
|
131
141
|
setVideoRef(localVideoRef);
|
|
132
142
|
}, [setVideoRef, localVideoRef]);
|
|
@@ -142,7 +152,7 @@ const VideoElement = forwardRef((props, ref) => {
|
|
|
142
152
|
// localVideoRef.current = videoElement;
|
|
143
153
|
// }
|
|
144
154
|
};
|
|
145
|
-
return (
|
|
155
|
+
return ((0, jsx_runtime_1.jsx)("video", { autoPlay: true, playsInline: true, ref: handleVideoRef, controls: false, src: ingest ? undefined : props.url, muted: muted, crossOrigin: "anonymous", onMouseMove: setUserInteraction, onClick: setUserInteraction, onAbort: event("abort"), onCanPlay: event("canplay"), onCanPlayThrough: canPlayThrough, onEmptied: event("emptied"), onEncrypted: event("encrypted"), onEnded: event("ended"), onError: event("error"), onLoadedData: event("loadeddata"), onLoadedMetadata: event("loadedmetadata"), onLoadStart: event("loadstart"), onPause: event("pause"), onPlay: event("play"), onPlaying: event("playing"), onRateChange: event("ratechange"), onSeeked: event("seeked"), onSeeking: event("seeking"), onStalled: event("stalled"), onSuspend: event("suspend"), onVolumeChange: event("volumechange"), onWaiting: event("waiting"), style: {
|
|
146
156
|
objectFit: "contain",
|
|
147
157
|
backgroundColor: "transparent",
|
|
148
158
|
width: "100%",
|
|
@@ -150,20 +160,20 @@ const VideoElement = forwardRef((props, ref) => {
|
|
|
150
160
|
transform: ingest ? "scaleX(-1)" : undefined,
|
|
151
161
|
} }));
|
|
152
162
|
});
|
|
153
|
-
|
|
154
|
-
return
|
|
163
|
+
function ProgressiveMP4Player(props) {
|
|
164
|
+
return (0, jsx_runtime_1.jsx)(VideoElement, { ...props });
|
|
155
165
|
}
|
|
156
|
-
|
|
157
|
-
return
|
|
166
|
+
function ProgressiveWebMPlayer(props) {
|
|
167
|
+
return (0, jsx_runtime_1.jsx)(VideoElement, { ...props });
|
|
158
168
|
}
|
|
159
|
-
|
|
160
|
-
const localRef = useRef(null);
|
|
161
|
-
useEffect(() => {
|
|
169
|
+
function HLSPlayer(props) {
|
|
170
|
+
const localRef = (0, react_1.useRef)(null);
|
|
171
|
+
(0, react_1.useEffect)(() => {
|
|
162
172
|
if (!localRef.current) {
|
|
163
173
|
return;
|
|
164
174
|
}
|
|
165
|
-
if (
|
|
166
|
-
var hls = new
|
|
175
|
+
if (hls_js_1.default.isSupported()) {
|
|
176
|
+
var hls = new hls_js_1.default({ maxAudioFramesDrift: 20 });
|
|
167
177
|
hls.loadSource(props.url);
|
|
168
178
|
try {
|
|
169
179
|
hls.attachMedia(localRef.current);
|
|
@@ -173,7 +183,7 @@ export function HLSPlayer(props) {
|
|
|
173
183
|
hls.stopLoad();
|
|
174
184
|
return;
|
|
175
185
|
}
|
|
176
|
-
hls.on(
|
|
186
|
+
hls.on(hls_js_1.default.Events.MANIFEST_PARSED, () => {
|
|
177
187
|
if (!localRef.current) {
|
|
178
188
|
return;
|
|
179
189
|
}
|
|
@@ -193,49 +203,49 @@ export function HLSPlayer(props) {
|
|
|
193
203
|
});
|
|
194
204
|
}
|
|
195
205
|
}, [props.url]);
|
|
196
|
-
return
|
|
206
|
+
return (0, jsx_runtime_1.jsx)(VideoElement, { ...props, ref: localRef });
|
|
197
207
|
}
|
|
198
|
-
|
|
199
|
-
const [webrtcError, setWebrtcError] = useState(null);
|
|
200
|
-
const setStatus = usePlayerStore((x) => x.setStatus);
|
|
201
|
-
const setProtocol = usePlayerStore((x) => x.setProtocol);
|
|
202
|
-
const diagnostics = useWebRTCDiagnostics();
|
|
208
|
+
function WebRTCPlayer(props) {
|
|
209
|
+
const [webrtcError, setWebrtcError] = (0, react_1.useState)(null);
|
|
210
|
+
const setStatus = (0, __1.usePlayerStore)((x) => x.setStatus);
|
|
211
|
+
const setProtocol = (0, __1.usePlayerStore)((x) => x.setProtocol);
|
|
212
|
+
const diagnostics = (0, webrtc_diagnostics_1.useWebRTCDiagnostics)();
|
|
203
213
|
// Check WebRTC compatibility on component mount
|
|
204
|
-
useEffect(() => {
|
|
214
|
+
(0, react_1.useEffect)(() => {
|
|
205
215
|
try {
|
|
206
|
-
checkWebRTCSupport();
|
|
216
|
+
(0, webrtc_primitives_1.checkWebRTCSupport)();
|
|
207
217
|
console.log("WebRTC Player - Browser compatibility check passed");
|
|
208
|
-
logWebRTCDiagnostics();
|
|
218
|
+
(0, webrtc_diagnostics_1.logWebRTCDiagnostics)();
|
|
209
219
|
}
|
|
210
220
|
catch (error) {
|
|
211
221
|
console.error("WebRTC Player - Compatibility error:", error.message);
|
|
212
222
|
setWebrtcError(error.message);
|
|
213
|
-
setStatus(PlayerStatus.START);
|
|
223
|
+
setStatus(__1.PlayerStatus.START);
|
|
214
224
|
return;
|
|
215
225
|
}
|
|
216
226
|
}, []);
|
|
217
227
|
// Monitor diagnostics for errors
|
|
218
|
-
useEffect(() => {
|
|
228
|
+
(0, react_1.useEffect)(() => {
|
|
219
229
|
if (!diagnostics.browserSupport && diagnostics.errors.length > 0) {
|
|
220
230
|
setWebrtcError(diagnostics.errors.join(", "));
|
|
221
231
|
}
|
|
222
232
|
}, [diagnostics]);
|
|
223
233
|
if (!diagnostics.done)
|
|
224
|
-
return
|
|
234
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
225
235
|
if (webrtcError) {
|
|
226
|
-
setProtocol(PlayerProtocol.HLS);
|
|
227
|
-
return (
|
|
236
|
+
setProtocol(__1.PlayerProtocol.HLS);
|
|
237
|
+
return ((0, jsx_runtime_1.jsx)(index_1.View, { backgroundColor: "#111", children: (0, jsx_runtime_1.jsxs)(index_1.View, { children: [(0, jsx_runtime_1.jsx)(index_1.View, { children: (0, jsx_runtime_1.jsx)(index_1.Text, { children: "WebRTC Not Supported" }) }), (0, jsx_runtime_1.jsx)(index_1.Text, { children: webrtcError }), diagnostics.errors.length > 0 && ((0, jsx_runtime_1.jsxs)(index_1.View, { children: [(0, jsx_runtime_1.jsx)(index_1.Text, { children: "Technical Details:" }), diagnostics.errors.map((error, index) => ((0, jsx_runtime_1.jsxs)(index_1.Text, { children: ["\u2022 ", error] }, index)))] })), (0, jsx_runtime_1.jsx)(index_1.Text, { children: "\u2022 To use WebRTC, you may need to disable any blocking extensions or update your browser." }), (0, jsx_runtime_1.jsx)(index_1.Text, { style: [atoms_1.mt[2]], children: "Switching to HLS..." })] }) }));
|
|
228
238
|
}
|
|
229
|
-
return
|
|
239
|
+
return (0, jsx_runtime_1.jsx)(WebRTCPlayerInner, { url: props.url, videoRef: props.videoRef });
|
|
230
240
|
}
|
|
231
|
-
|
|
232
|
-
const [connectionStatus, setConnectionStatus] = useState("initializing");
|
|
233
|
-
const status = usePlayerStore((x) => x.status);
|
|
234
|
-
const setStatus = usePlayerStore((x) => x.setStatus);
|
|
235
|
-
const playerEvent = usePlayerStore((x) => x.playerEvent);
|
|
236
|
-
const spurl = useStreamplaceStore((x) => x.url);
|
|
237
|
-
const [mediaStream, stuck] =
|
|
238
|
-
useEffect(() => {
|
|
241
|
+
function WebRTCPlayerInner({ videoRef, url, width, height, }) {
|
|
242
|
+
const [connectionStatus, setConnectionStatus] = (0, react_1.useState)("initializing");
|
|
243
|
+
const status = (0, __1.usePlayerStore)((x) => x.status);
|
|
244
|
+
const setStatus = (0, __1.usePlayerStore)((x) => x.setStatus);
|
|
245
|
+
const playerEvent = (0, __1.usePlayerStore)((x) => x.playerEvent);
|
|
246
|
+
const spurl = (0, __1.useStreamplaceStore)((x) => x.url);
|
|
247
|
+
const [mediaStream, stuck] = (0, use_webrtc_1.default)(url);
|
|
248
|
+
(0, react_1.useEffect)(() => {
|
|
239
249
|
if (stuck) {
|
|
240
250
|
setConnectionStatus("connection-failed");
|
|
241
251
|
}
|
|
@@ -246,15 +256,15 @@ export function WebRTCPlayerInner({ videoRef, url, width, height, }) {
|
|
|
246
256
|
setConnectionStatus("connecting");
|
|
247
257
|
}
|
|
248
258
|
}, [url, mediaStream, stuck, status]);
|
|
249
|
-
useEffect(() => {
|
|
250
|
-
if (stuck && status === PlayerStatus.PLAYING) {
|
|
251
|
-
setStatus(PlayerStatus.STALLED);
|
|
259
|
+
(0, react_1.useEffect)(() => {
|
|
260
|
+
if (stuck && status === __1.PlayerStatus.PLAYING) {
|
|
261
|
+
setStatus(__1.PlayerStatus.STALLED);
|
|
252
262
|
}
|
|
253
263
|
if (!stuck && mediaStream) {
|
|
254
|
-
setStatus(PlayerStatus.PLAYING);
|
|
264
|
+
setStatus(__1.PlayerStatus.PLAYING);
|
|
255
265
|
}
|
|
256
266
|
}, [stuck, status, mediaStream]);
|
|
257
|
-
useEffect(() => {
|
|
267
|
+
(0, react_1.useEffect)(() => {
|
|
258
268
|
if (!mediaStream) {
|
|
259
269
|
return;
|
|
260
270
|
}
|
|
@@ -286,37 +296,37 @@ export function WebRTCPlayerInner({ videoRef, url, width, height, }) {
|
|
|
286
296
|
mediaStream.removeEventListener("ended", ended);
|
|
287
297
|
};
|
|
288
298
|
}, [mediaStream]);
|
|
289
|
-
useEffect(() => {
|
|
299
|
+
(0, react_1.useEffect)(() => {
|
|
290
300
|
if (!videoRef || !videoRef.current) {
|
|
291
301
|
return;
|
|
292
302
|
}
|
|
293
303
|
videoRef.current.srcObject = mediaStream;
|
|
294
304
|
}, [mediaStream]);
|
|
295
305
|
if (!mediaStream) {
|
|
296
|
-
return (
|
|
306
|
+
return ((0, jsx_runtime_1.jsx)(index_1.View, { backgroundColor: "#111", style: { minWidth: "100%", minHeight: "100%" }, children: (0, jsx_runtime_1.jsxs)(index_1.View, { backgroundColor: atoms_1.colors.primary[800], style: { borderRadius: atoms_1.borderRadius.md }, children: [(0, jsx_runtime_1.jsx)(index_1.View, { children: (0, jsx_runtime_1.jsx)(index_1.Text, { children: "Connecting..." }) }), (0, jsx_runtime_1.jsxs)(index_1.Text, { children: ["Establishing WebRTC connection (", connectionStatus, ")"] })] }) }));
|
|
297
307
|
}
|
|
298
|
-
return
|
|
308
|
+
return (0, jsx_runtime_1.jsx)(VideoElement, { url: url, ref: videoRef });
|
|
299
309
|
}
|
|
300
|
-
|
|
301
|
-
const ingestStarting = usePlayerStore((x) => x.ingestStarting);
|
|
302
|
-
const ingestMediaSource = usePlayerStore((x) => x.ingestMediaSource);
|
|
303
|
-
const ingestAutoStart = usePlayerStore((x) => x.ingestAutoStart);
|
|
304
|
-
const [error, setError] = useState(null);
|
|
310
|
+
function WebcamIngestPlayer(props) {
|
|
311
|
+
const ingestStarting = (0, __1.usePlayerStore)((x) => x.ingestStarting);
|
|
312
|
+
const ingestMediaSource = (0, __1.usePlayerStore)((x) => x.ingestMediaSource);
|
|
313
|
+
const ingestAutoStart = (0, __1.usePlayerStore)((x) => x.ingestAutoStart);
|
|
314
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
305
315
|
let streamKey = null;
|
|
306
|
-
const [videoElement, setVideoElement] = useState(null);
|
|
307
|
-
const handleRef = useCallback((node) => {
|
|
316
|
+
const [videoElement, setVideoElement] = (0, react_1.useState)(null);
|
|
317
|
+
const handleRef = (0, react_1.useCallback)((node) => {
|
|
308
318
|
if (node) {
|
|
309
319
|
setVideoElement(node);
|
|
310
320
|
}
|
|
311
321
|
}, []);
|
|
312
|
-
const url = useStreamplaceStore((x) => x.url);
|
|
313
|
-
const [localMediaStream, setLocalMediaStream] = useState(null);
|
|
322
|
+
const url = (0, __1.useStreamplaceStore)((x) => x.url);
|
|
323
|
+
const [localMediaStream, setLocalMediaStream] = (0, react_1.useState)(null);
|
|
314
324
|
// we assign a stream key in the webrtcingest hook
|
|
315
|
-
const [remoteMediaStream, setRemoteMediaStream] = useWebRTCIngest({
|
|
325
|
+
const [remoteMediaStream, setRemoteMediaStream] = (0, use_webrtc_1.useWebRTCIngest)({
|
|
316
326
|
endpoint: `${url}/api/ingest/webrtc`,
|
|
317
327
|
});
|
|
318
|
-
useEffect(() => {
|
|
319
|
-
if (ingestMediaSource === IngestMediaSource.DISPLAY) {
|
|
328
|
+
(0, react_1.useEffect)(() => {
|
|
329
|
+
if (ingestMediaSource === __1.IngestMediaSource.DISPLAY) {
|
|
320
330
|
navigator.mediaDevices
|
|
321
331
|
.getDisplayMedia({
|
|
322
332
|
audio: true,
|
|
@@ -349,7 +359,7 @@ export function WebcamIngestPlayer(props) {
|
|
|
349
359
|
});
|
|
350
360
|
}
|
|
351
361
|
}, [ingestMediaSource]);
|
|
352
|
-
useEffect(() => {
|
|
362
|
+
(0, react_1.useEffect)(() => {
|
|
353
363
|
if (!ingestStarting && !ingestAutoStart) {
|
|
354
364
|
setRemoteMediaStream(null);
|
|
355
365
|
return;
|
|
@@ -359,7 +369,7 @@ export function WebcamIngestPlayer(props) {
|
|
|
359
369
|
}
|
|
360
370
|
setRemoteMediaStream(localMediaStream);
|
|
361
371
|
}, [localMediaStream, ingestStarting, ingestAutoStart]);
|
|
362
|
-
useEffect(() => {
|
|
372
|
+
(0, react_1.useEffect)(() => {
|
|
363
373
|
if (!videoElement) {
|
|
364
374
|
return;
|
|
365
375
|
}
|
|
@@ -369,7 +379,7 @@ export function WebcamIngestPlayer(props) {
|
|
|
369
379
|
videoElement.srcObject = localMediaStream;
|
|
370
380
|
}, [videoElement, localMediaStream]);
|
|
371
381
|
if (error) {
|
|
372
|
-
return (
|
|
382
|
+
return ((0, jsx_runtime_1.jsxs)(index_1.View, { backgroundColor: atoms_1.colors.destructive[900], style: [atoms_1.p[4], { borderRadius: atoms_1.borderRadius.md }], children: [(0, jsx_runtime_1.jsx)(index_1.View, { children: (0, jsx_runtime_1.jsx)(index_1.Text, { size: "xl", weight: "extrabold", children: "Error encountered!" }) }), (0, jsx_runtime_1.jsx)(index_1.Text, { children: error.message })] }));
|
|
373
383
|
}
|
|
374
|
-
return
|
|
384
|
+
return (0, jsx_runtime_1.jsx)(VideoElement, { ...props, ref: handleRef });
|
|
375
385
|
}
|