kasunk99-livestream-core 0.3.4 → 0.3.6
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.
|
@@ -205,7 +205,7 @@ export const LiveStreamViewerItem = memo(function LiveStreamViewerItem({ stream,
|
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
};
|
|
208
|
-
return (_jsxs(View, { style: styles.container, children: [showVideo && RTCViewComponent && streamURL ? (_jsx(RTCViewComponent, { streamURL: streamURL, stream: displayStream, style: styles.rtcView, objectFit: "
|
|
208
|
+
return (_jsxs(View, { style: styles.container, children: [showVideo && RTCViewComponent && streamURL ? (_jsx(RTCViewComponent, { streamURL: streamURL, stream: displayStream, style: styles.rtcView, objectFit: "cover", mirror: false }, `rtc-${trackCount}-${streamURL}`)) : (_jsxs(View, { style: styles.videoPlaceholder, children: [joining && _jsx(Text, { style: styles.placeholderText, children: "Joining..." }), error && _jsx(Text, { style: [styles.placeholderText, styles.errorText], children: error }), joined && !joining && !error && (_jsxs(_Fragment, { children: [_jsx(Text, { style: styles.liveBadge, children: "LIVE" }), _jsx(Text, { style: styles.placeholderText, children: stream.roomId }), hasVideo && webrtcUnavailable && (_jsxs(Text, { style: [styles.hintText, styles.warnText], children: ["Video needs a development build.", '\n', "Run: npx expo run:android"] })), hasVideo && consumeError && (_jsx(Text, { style: [styles.hintText, styles.errorText], children: consumeError })), hasVideo && !remoteStream && !webrtcUnavailable && !consumeError && (_jsx(Text, { style: styles.hintText, children: "Loading video..." })), !hasVideo && joined && producerList.length === 0 && (_jsxs(Text, { style: [styles.hintText, styles.warnText], children: ["Host has not started camera yet.", '\n', "Use a web client to stream, or wait for host to produce."] })), hasVideo && remoteStream && !RTCViewComponent && (_jsx(Text, { style: styles.hintText, children: "Video received (use dev build to see it)" })), hasVideo && remoteStream && RTCViewComponent && !hasVideoTrack && (_jsx(Text, { style: [styles.hintText, styles.warnText], children: "Audio only (no video track yet)" })), hasVideo && remoteStream && hasVideoTrack && !streamURL && (_jsx(Text, { style: [styles.hintText, styles.warnText], children: "Video track received but cannot display (need dev build with react-native-webrtc)" }))] }))] })), _jsxs(View, { style: styles.overlay, children: [_jsxs(View, { style: styles.topMeta, children: [_jsx(View, { style: styles.row, children: _jsxs(Text, { style: styles.roomId, numberOfLines: 1, children: ["LIVE \u00B7 ", stream.hostDisplayName || stream.title || stream.roomId] }) }), _jsx(View, { style: styles.stats, children: _jsxs(Text, { style: styles.statsText, children: ["\uD83D\uDC41 ", viewerCount] }) })] }), _jsx(Animated.View, { style: [styles.chatPanel, { bottom: chatBottomAnim }], pointerEvents: "box-none", children: _jsxs(ScrollView, { scrollEnabled: false, keyboardShouldPersistTaps: "always", contentContainerStyle: styles.chatStack, children: [_jsx(View, { style: styles.chatListWrapper, children: _jsx(ScrollView, { ref: chatListRef, contentContainerStyle: styles.chatListContent, showsVerticalScrollIndicator: false, keyboardDismissMode: "on-drag", keyboardShouldPersistTaps: "always", nestedScrollEnabled: true, children: chatData.map((item) => (_jsxs(Text, { style: styles.chatLine, numberOfLines: 2, children: [_jsx(Text, { style: [styles.chatName, { color: getNameColor(item.displayName) }], children: item.displayName }), _jsxs(Text, { style: styles.chatText, children: [" ", item.text] })] }, item.id))) }) }), _jsxs(View, { style: styles.chatInputRow, children: [_jsx(TextInput, { style: styles.chatInput, value: chatInput, onChangeText: setChatInput, placeholder: joined ? 'Say something...' : 'Connecting...', placeholderTextColor: "#9ca3af", editable: joined && !joining && !error, onSubmitEditing: sendChat, returnKeyType: "send" }), _jsx(TouchableOpacity, { onPress: sendChat, disabled: !joined || joining || !!error || !chatInput.trim(), style: [
|
|
209
209
|
styles.chatSendButton,
|
|
210
210
|
(!joined || joining || !!error || !chatInput.trim()) && styles.chatSendButtonDisabled,
|
|
211
211
|
], children: _jsx(Text, { style: styles.chatSendText, children: "\u27A4" }) })] })] }) })] })] }));
|
|
@@ -249,8 +249,8 @@ export function useHostSocket(options = {}) {
|
|
|
249
249
|
video: {
|
|
250
250
|
facingMode: front ? 'user' : 'environment',
|
|
251
251
|
frameRate: 30,
|
|
252
|
-
width:
|
|
253
|
-
height:
|
|
252
|
+
width: { ideal: 1080, max: 1080 },
|
|
253
|
+
height: { ideal: 1920, max: 1920 },
|
|
254
254
|
},
|
|
255
255
|
}));
|
|
256
256
|
hostSession.localStream = stream;
|
|
@@ -312,7 +312,7 @@ export function useHostSocket(options = {}) {
|
|
|
312
312
|
hostSession.videoProducer = null;
|
|
313
313
|
const producer = await transport.produce({
|
|
314
314
|
track: newTrack,
|
|
315
|
-
encodings: [{ maxBitrate:
|
|
315
|
+
encodings: [{ maxBitrate: 2500000 }],
|
|
316
316
|
codecOptions: { videoSimulcastLayers: [] },
|
|
317
317
|
});
|
|
318
318
|
hostSession.videoProducer = producer;
|
|
@@ -353,8 +353,8 @@ export function useHostSocket(options = {}) {
|
|
|
353
353
|
video: {
|
|
354
354
|
facingMode: front ? 'user' : 'environment',
|
|
355
355
|
frameRate: 30,
|
|
356
|
-
width:
|
|
357
|
-
height:
|
|
356
|
+
width: { ideal: 1080, max: 1080 },
|
|
357
|
+
height: { ideal: 1920, max: 1920 },
|
|
358
358
|
},
|
|
359
359
|
}));
|
|
360
360
|
// fullCleanup may have run while awaiting getUserMedia
|
|
@@ -557,7 +557,7 @@ export function useHostSocket(options = {}) {
|
|
|
557
557
|
for (const track of tracksToPublish) {
|
|
558
558
|
const producer = await transport.produce({
|
|
559
559
|
track: track,
|
|
560
|
-
encodings: track.kind === 'video' ? [{ maxBitrate:
|
|
560
|
+
encodings: track.kind === 'video' ? [{ maxBitrate: 2500000 }] : undefined,
|
|
561
561
|
codecOptions: track.kind === 'video'
|
|
562
562
|
? { videoSimulcastLayers: [] }
|
|
563
563
|
: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewerSocket.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewerSocket.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM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AAG,IAAI,CAAC;IAC/B,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmgBpG"}
|
|
@@ -104,6 +104,7 @@ export function useViewerSocket(roomId) {
|
|
|
104
104
|
});
|
|
105
105
|
}, JOIN_TIMEOUT_MS);
|
|
106
106
|
let socket = null;
|
|
107
|
+
let sysAudioPlayerStarted = false;
|
|
107
108
|
(async () => {
|
|
108
109
|
// Server requires viewerToken for viewers (not merchant apiKey).
|
|
109
110
|
// We mint a short-lived viewer token via HTTP using the apiKey.
|
|
@@ -200,6 +201,31 @@ export function useViewerSocket(roomId) {
|
|
|
200
201
|
setState((prev) => ({ ...prev, viewerCount: payload.viewerCount }));
|
|
201
202
|
}
|
|
202
203
|
});
|
|
204
|
+
socket.on('system-audio-chunk', (payload) => {
|
|
205
|
+
const b64 = typeof payload === 'string' ? payload
|
|
206
|
+
: typeof payload?.data === 'string'
|
|
207
|
+
? payload.data
|
|
208
|
+
: null;
|
|
209
|
+
if (!b64)
|
|
210
|
+
return;
|
|
211
|
+
try {
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
213
|
+
const { NativeModules, Platform } = require('react-native');
|
|
214
|
+
if (Platform.OS !== 'android')
|
|
215
|
+
return;
|
|
216
|
+
const player = NativeModules.ScreenSystemAudioPlayer;
|
|
217
|
+
if (!player)
|
|
218
|
+
return;
|
|
219
|
+
if (!sysAudioPlayerStarted) {
|
|
220
|
+
sysAudioPlayerStarted = true;
|
|
221
|
+
player.startPlayback().catch(() => { sysAudioPlayerStarted = false; });
|
|
222
|
+
}
|
|
223
|
+
player.feedChunk(b64);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// NativeModules unavailable in non-RN environments
|
|
227
|
+
}
|
|
228
|
+
});
|
|
203
229
|
})();
|
|
204
230
|
return () => {
|
|
205
231
|
clearTimeout(joinTimeout);
|
|
@@ -210,6 +236,18 @@ export function useViewerSocket(roomId) {
|
|
|
210
236
|
catch {
|
|
211
237
|
// ignore
|
|
212
238
|
}
|
|
239
|
+
if (sysAudioPlayerStarted) {
|
|
240
|
+
sysAudioPlayerStarted = false;
|
|
241
|
+
try {
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
243
|
+
const { NativeModules } = require('react-native');
|
|
244
|
+
const player = NativeModules.ScreenSystemAudioPlayer;
|
|
245
|
+
player?.stopPlayback?.();
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// ignore
|
|
249
|
+
}
|
|
250
|
+
}
|
|
213
251
|
disconnect();
|
|
214
252
|
};
|
|
215
253
|
}, [roomId, disconnect]);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAClG,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACnH,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGvF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED