[mirotalk] - fix mic audio after screen stop
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
# ====================================================
|
||||
# MiroTalk P2P v.1.7.06 - Environment Configuration
|
||||
# MiroTalk P2P v.1.7.07 - Environment Configuration
|
||||
# ====================================================
|
||||
|
||||
# App environment
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* ==============================================
|
||||
* MiroTalk P2P v.1.7.06 - Configuration File
|
||||
* MiroTalk P2P v.1.7.07 - Configuration File
|
||||
* ==============================================
|
||||
*
|
||||
* Branding and customizations require a license:
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ dependencies: {
|
||||
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.7.06
|
||||
* @version 1.7.07
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mirotalk",
|
||||
"version": "1.7.06",
|
||||
"version": "1.7.07",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mirotalk",
|
||||
"version": "1.7.06",
|
||||
"version": "1.7.07",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@mattermost/client": "11.2.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mirotalk",
|
||||
"version": "1.7.06",
|
||||
"version": "1.7.07",
|
||||
"description": "A free WebRTC browser-based video call",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ let brand = {
|
||||
},
|
||||
about: {
|
||||
imageUrl: '../images/mirotalk-logo.gif',
|
||||
title: 'WebRTC P2P v1.7.06',
|
||||
title: 'WebRTC P2P v1.7.07',
|
||||
html: `
|
||||
<button
|
||||
id="support-button"
|
||||
|
||||
+27
-17
@@ -15,7 +15,7 @@
|
||||
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.7.06
|
||||
* @version 1.7.07
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -7984,7 +7984,22 @@ async function toggleScreenSharing(init = false) {
|
||||
peerInfo.extras = {};
|
||||
} catch (_) {}
|
||||
await emitPeerStatus('screen', false, {});
|
||||
await refreshMyStreamToPeers(undefined, true);
|
||||
|
||||
// Ensure mic audio is restored
|
||||
let micTrack = getAudioTrack(localAudioMediaStream);
|
||||
if (!micTrack || micTrack.readyState === 'ended') {
|
||||
try {
|
||||
const micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
localAudioMediaStream = micStream;
|
||||
micTrack = getAudioTrack(localAudioMediaStream);
|
||||
console.log('Reacquired microphone after screen share stop');
|
||||
} catch (err) {
|
||||
console.error('Failed to reacquire microphone after screen share stop:', err);
|
||||
}
|
||||
} else {
|
||||
micTrack.enabled = true;
|
||||
}
|
||||
await refreshMyStreamToPeers(localAudioMediaStream, true);
|
||||
|
||||
// Screen reader announcement for stopping screen share
|
||||
screenReaderAccessibility.announceMessage('Screen sharing stopped');
|
||||
@@ -8192,16 +8207,15 @@ async function refreshMyStreamToPeers(stream, localAudioTrackChange = false) {
|
||||
|
||||
// Determine which audio track to use.
|
||||
// While screen sharing, prefer the screen-share audio track (which may be mixed screen+mic).
|
||||
const screenAudioTrack =
|
||||
isScreenStreaming && hasAudioTrack(localScreenMediaStream) ? getAudioTrack(localScreenMediaStream) : null;
|
||||
|
||||
const micCandidate =
|
||||
stream && hasAudioTrack(stream) && localAudioTrackChange
|
||||
? getAudioTrack(stream)
|
||||
: getAudioTrack(localAudioMediaStream);
|
||||
|
||||
const audioTrack = screenAudioTrack || micCandidate;
|
||||
const audioStream = screenAudioTrack ? localScreenMediaStream : localAudioMediaStream;
|
||||
// Always prefer mic audio when not screen sharing
|
||||
let audioTrack, audioStream;
|
||||
if (isScreenStreaming && hasAudioTrack(localScreenMediaStream)) {
|
||||
audioTrack = getAudioTrack(localScreenMediaStream);
|
||||
audioStream = localScreenMediaStream;
|
||||
} else {
|
||||
audioTrack = getAudioTrack(localAudioMediaStream);
|
||||
audioStream = localAudioMediaStream;
|
||||
}
|
||||
|
||||
// Push tracks to every peer
|
||||
for (const peer_id in peerConnections) {
|
||||
@@ -8223,10 +8237,7 @@ async function refreshMyStreamToPeers(stream, localAudioTrackChange = false) {
|
||||
console.log('ADD CAMERA TRACK TO', { peer_id, peer_name, cameraTrack });
|
||||
}
|
||||
} else {
|
||||
// No camera track: if there's a camera sender (but no screen or screen is at index 0), handle cleanup
|
||||
// Note: We keep video senders if screen exists; this branch handles pure camera removal
|
||||
if (videoSenders.length >= 1 && !screenTrack) {
|
||||
// Only remove the first sender if there's no screen to take its place
|
||||
try {
|
||||
await videoSenders[0].replaceTrack(null);
|
||||
console.log('REMOVE CAMERA TRACK FROM', { peer_id, peer_name });
|
||||
@@ -8247,7 +8258,6 @@ async function refreshMyStreamToPeers(stream, localAudioTrackChange = false) {
|
||||
console.log('ADD SCREEN TRACK TO', { peer_id, peer_name, screenTrack });
|
||||
}
|
||||
} else {
|
||||
// No screen track: if there are 2 video senders, remove the second one
|
||||
if (videoSenders.length >= 2) {
|
||||
try {
|
||||
pc.removeTrack(videoSenders[1]);
|
||||
@@ -13598,7 +13608,7 @@ function showAbout() {
|
||||
Swal.fire({
|
||||
background: swBg,
|
||||
position: 'center',
|
||||
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.7.06',
|
||||
title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.7.07',
|
||||
imageUrl: brand.about?.imageUrl && brand.about.imageUrl.trim() !== '' ? brand.about.imageUrl : images.about,
|
||||
customClass: { image: 'img-about' },
|
||||
html: `
|
||||
|
||||
Reference in New Issue
Block a user