mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
maybe finally fix double audio
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@
|
|||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
||||||
<title>Multi Roomba Rover</title>
|
<title>Multi Roomba Rover</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CVZhRUxX.js"></script>
|
<script type="module" crossorigin src="/assets/index-ByiKIpTV.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-Bz1ixYh7.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-Bz1ixYh7.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ export default function VideoTile({
|
|||||||
url: sessionInfo.url,
|
url: sessionInfo.url,
|
||||||
token: sessionInfo.token,
|
token: sessionInfo.token,
|
||||||
video: videoRef.current,
|
video: videoRef.current,
|
||||||
|
receiveAudio: !hasDedicatedAudio,
|
||||||
onStatus: handleStatus,
|
onStatus: handleStatus,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -306,7 +307,7 @@ export default function VideoTile({
|
|||||||
clearTimeout(resetMuteId);
|
clearTimeout(resetMuteId);
|
||||||
player?.stop();
|
player?.stop();
|
||||||
};
|
};
|
||||||
}, [usingSnapshot, sessionInfo?.url, sessionInfo?.token, restartToken, scheduleRestart, ensurePlayback]);
|
}, [usingSnapshot, sessionInfo?.url, sessionInfo?.token, restartToken, scheduleRestart, ensurePlayback, hasDedicatedAudio]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === 'stopped' && sessionInfo?.url) {
|
if (status === 'stopped' && sessionInfo?.url) {
|
||||||
@@ -330,7 +331,8 @@ export default function VideoTile({
|
|||||||
if (graphReady) {
|
if (graphReady) {
|
||||||
const compressor = audioCompressorRef.current;
|
const compressor = audioCompressorRef.current;
|
||||||
const gainNode = audioGainRef.current;
|
const gainNode = audioGainRef.current;
|
||||||
audioEl.volume = 1;
|
// Keep element output at zero; audio should come only from WebAudio graph.
|
||||||
|
audioEl.volume = 0;
|
||||||
if (gainNode) {
|
if (gainNode) {
|
||||||
gainNode.gain.value = effectiveRoverGain;
|
gainNode.gain.value = effectiveRoverGain;
|
||||||
}
|
}
|
||||||
@@ -354,7 +356,7 @@ export default function VideoTile({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasGraph = Boolean(audioSourceNodeRef.current && audioGainRef.current);
|
const hasGraph = Boolean(audioSourceNodeRef.current && audioGainRef.current);
|
||||||
audioEl.volume = hasGraph ? 1 : effectiveRoverGain;
|
audioEl.volume = hasGraph ? 0 : effectiveRoverGain;
|
||||||
if (audioCompressorRef.current) {
|
if (audioCompressorRef.current) {
|
||||||
audioCompressorRef.current.threshold.value = 0;
|
audioCompressorRef.current.threshold.value = 0;
|
||||||
audioCompressorRef.current.knee.value = 0;
|
audioCompressorRef.current.knee.value = 0;
|
||||||
|
|||||||
@@ -27,11 +27,12 @@ function buildAuthHeader(token) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class WhepPlayer {
|
export class WhepPlayer {
|
||||||
constructor({ url, token, video, onStatus, audioOnly = false }) {
|
constructor({ url, token, video, onStatus, audioOnly = false, receiveAudio = true }) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.video = video;
|
this.video = video;
|
||||||
this.audioOnly = audioOnly;
|
this.audioOnly = audioOnly;
|
||||||
|
this.receiveAudio = receiveAudio;
|
||||||
this.pc = null;
|
this.pc = null;
|
||||||
this.abortController = null;
|
this.abortController = null;
|
||||||
this.onStatus = onStatus;
|
this.onStatus = onStatus;
|
||||||
@@ -78,7 +79,9 @@ export class WhepPlayer {
|
|||||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||||
} else {
|
} else {
|
||||||
pc.addTransceiver('video', { direction: 'recvonly' });
|
pc.addTransceiver('video', { direction: 'recvonly' });
|
||||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
if (this.receiveAudio) {
|
||||||
|
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.onconnectionstatechange = () => {
|
pc.onconnectionstatechange = () => {
|
||||||
@@ -93,7 +96,7 @@ export class WhepPlayer {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const offer = await pc.createOffer({
|
const offer = await pc.createOffer({
|
||||||
offerToReceiveAudio: true,
|
offerToReceiveAudio: this.audioOnly ? true : this.receiveAudio,
|
||||||
offerToReceiveVideo: !this.audioOnly,
|
offerToReceiveVideo: !this.audioOnly,
|
||||||
});
|
});
|
||||||
await pc.setLocalDescription(offer);
|
await pc.setLocalDescription(offer);
|
||||||
|
|||||||
Reference in New Issue
Block a user