[mirotalksfu] - fix audio

هذا الالتزام موجود في:
Miroslav Pejic
2024-02-05 21:23:13 +01:00
الأصل 23963b0aec
التزام c907559282
2 ملفات معدلة مع 20 إضافات و7 حذوفات

عرض الملف

@@ -73,6 +73,9 @@ const wbHeight = 600;
const swalImageUrl = '../images/pricing-illustration.svg';
// Media
const sinkId = 'sinkId' in HTMLMediaElement.prototype;
// ####################################################
// LOCAL STORAGE
// ####################################################
@@ -447,7 +450,6 @@ async function enumerateAudioDevices(stream) {
.then(async () => {
await stopTracks(stream);
isEnumerateAudioDevices = true;
const sinkId = 'sinkId' in HTMLMediaElement.prototype;
speakerSelect.disabled = !sinkId;
// Check if there is speakers
if (!sinkId || initSpeakerSelect.options.length === 0) {
@@ -1606,8 +1608,7 @@ async function setSelectsInit() {
current: speakerSelect.value,
});
// TODO: Fix me, keep for now always default speaker...
if (true || !initSpeakerExist || !speakerExist) {
if (!initSpeakerExist || !speakerExist) {
console.log('04.2 ----> Speaker devices seems changed, use default index 0');
initSpeakerSelect.selectedIndex = 0;
speakerSelect.selectedIndex = 0;
@@ -1765,7 +1766,7 @@ function handleSelects() {
refreshLsDevices();
};
speakerSelect.onchange = () => {
rc.attachSinkId(rc.myAudioEl, speakerSelect.value);
rc.changeAudioDestination();
refreshLsDevices();
};
switchPushToTalk.onchange = (e) => {

عرض الملف

@@ -1697,9 +1697,6 @@ class RoomClient {
this.myAudioEl = elem;
this.localAudioEl.appendChild(elem);
this.attachMediaStream(elem, stream, type, 'Producer');
if (this.isAudioAllowed && !this._moderator.audio_start_muted && !speakerSelect.disabled) {
this.attachSinkId(elem, speakerSelect.value);
}
console.log('[addProducer] audio-element-count', this.localAudioEl.childElementCount);
break;
default:
@@ -2104,6 +2101,9 @@ class RoomClient {
this.handlePV(id + '___' + audioConsumerId);
this.setPeerAudio(remotePeerId, remotePeerAudio);
}
if (sinkId && speakerSelect.value) {
this.changeAudioDestination(elem);
}
console.log('[Add audioConsumers]', this.audioConsumers);
break;
default:
@@ -2377,6 +2377,18 @@ class RoomClient {
console.log(who + ' Success attached media ' + type);
}
async changeAudioDestination(audioElement = false) {
const audioDestination = speakerSelect.value;
if (audioElement) {
await this.attachSinkId(audioElement, audioDestination);
} else {
const audioElements = this.remoteAudioEl.querySelectorAll('audio');
audioElements.forEach(async (audioElement) => {
await this.attachSinkId(audioElement, audioDestination);
});
}
}
async attachSinkId(elem, sinkId) {
if (typeof elem.sinkId !== 'undefined') {
elem.setSinkId(sinkId)