Autosave: 20260217-152131
This commit is contained in:
parent
24671bdbc7
commit
c11359b2d2
@ -681,9 +681,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const channelId = voiceItem.dataset.channelId;
|
||||
if (voiceHandler) {
|
||||
if (voiceHandler.currentChannelId == channelId) {
|
||||
console.log('Leaving voice channel:', channelId);
|
||||
voiceHandler.leave();
|
||||
voiceItem.classList.remove('active');
|
||||
console.log('Already in this channel:', channelId);
|
||||
return;
|
||||
} else {
|
||||
console.log('Joining voice channel:', channelId);
|
||||
voiceHandler.join(channelId);
|
||||
|
||||
@ -265,15 +265,31 @@ class VoiceChannel {
|
||||
}
|
||||
|
||||
setupVOX() {
|
||||
if (this.audioContext) {
|
||||
if (this.audioContext.state === 'suspended') {
|
||||
this.audioContext.resume();
|
||||
}
|
||||
if (!this.localStream) {
|
||||
console.warn('Cannot setup VOX: no localStream');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log('Setting up VOX logic...');
|
||||
try {
|
||||
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
if (!this.audioContext) {
|
||||
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
}
|
||||
|
||||
// Re-ensure context is running
|
||||
if (this.audioContext.state === 'suspended') {
|
||||
this.audioContext.resume().then(() => console.log('AudioContext resumed'));
|
||||
}
|
||||
|
||||
// Cleanup old nodes
|
||||
if (this.scriptProcessor) {
|
||||
this.scriptProcessor.onaudioprocess = null;
|
||||
try { this.scriptProcessor.disconnect(); } catch(e) {}
|
||||
}
|
||||
if (this.microphone) {
|
||||
try { this.microphone.disconnect(); } catch(e) {}
|
||||
}
|
||||
|
||||
this.analyser = this.audioContext.createAnalyser();
|
||||
this.analyser.fftSize = 512;
|
||||
this.microphone = this.audioContext.createMediaStreamSource(this.localStream);
|
||||
@ -282,7 +298,8 @@ class VoiceChannel {
|
||||
this.microphone.connect(this.analyser);
|
||||
this.analyser.connect(this.scriptProcessor);
|
||||
this.scriptProcessor.connect(this.audioContext.destination);
|
||||
|
||||
|
||||
this.voxActive = false;
|
||||
this.currentVolume = 0;
|
||||
|
||||
this.scriptProcessor.onaudioprocess = () => {
|
||||
@ -311,6 +328,7 @@ class VoiceChannel {
|
||||
}
|
||||
}
|
||||
};
|
||||
console.log('VOX logic setup complete');
|
||||
} catch (e) {
|
||||
console.error('Failed to setup VOX:', e);
|
||||
}
|
||||
@ -360,9 +378,21 @@ class VoiceChannel {
|
||||
this.localStream.getTracks().forEach(track => track.stop());
|
||||
this.localStream = null;
|
||||
}
|
||||
if (this.audioContext) {
|
||||
this.audioContext.close();
|
||||
this.audioContext = null;
|
||||
|
||||
if (this.scriptProcessor) {
|
||||
try {
|
||||
this.scriptProcessor.disconnect();
|
||||
this.scriptProcessor.onaudioprocess = null;
|
||||
} catch(e) {}
|
||||
this.scriptProcessor = null;
|
||||
}
|
||||
if (this.microphone) {
|
||||
try { this.microphone.disconnect(); } catch(e) {}
|
||||
this.microphone = null;
|
||||
}
|
||||
if (this.audioContext && this.audioContext.state !== 'closed') {
|
||||
// Keep AudioContext alive but suspended to reuse it
|
||||
this.audioContext.suspend();
|
||||
}
|
||||
|
||||
Object.values(this.peers).forEach(pc => pc.close());
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"candidate:1 1 UDP 1686052863 78.246.210.10 31075 typ srflx raddr 192.168.26.26 rport 52078","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579696}
|
||||
{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"candidate:1 2 UDP 1686052862 78.246.210.10 31078 typ srflx raddr 192.168.26.26 rport 52079","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579740}
|
||||
{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579742}
|
||||
@ -1 +1 @@
|
||||
{"45a8f0c9dde7c4a2":{"id":"45a8f0c9dde7c4a2","user_id":2,"name":"swefpifh ᵇʰᶠʳ","avatar_url":"","last_seen":1771340822998}}
|
||||
[]
|
||||
@ -1 +1 @@
|
||||
{"1e0897d1dcb980dc":{"id":"1e0897d1dcb980dc","user_id":3,"name":"swefheim","avatar_url":"","last_seen":1771340822155}}
|
||||
{"f9f747081f54c6e3":{"id":"f9f747081f54c6e3","user_id":2,"name":"swefpifh ᵇʰᶠʳ","avatar_url":"","last_seen":1771341691097}}
|
||||
26
index.php
26
index.php
@ -1325,17 +1325,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const voiceTabBtn = document.querySelector('[data-bs-target="#settings-voice"]');
|
||||
if (voiceTabBtn) {
|
||||
voiceTabBtn.addEventListener('shown.bs.tab', async () => {
|
||||
if (window.voiceHandler && !window.voiceHandler.localStream) {
|
||||
try {
|
||||
console.log('Voice tab active, requesting mic for preview...');
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
window.voiceHandler.localStream = stream;
|
||||
if (window.voiceHandler) {
|
||||
if (!window.voiceHandler.localStream) {
|
||||
try {
|
||||
console.log('Voice tab active, requesting mic for preview...');
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
window.voiceHandler.localStream = stream;
|
||||
window.voiceHandler.setupVOX();
|
||||
} catch (e) {
|
||||
console.error('Failed to get mic for preview:', e);
|
||||
}
|
||||
} else {
|
||||
console.log('Voice tab active, using existing localStream for preview');
|
||||
window.voiceHandler.setupVOX();
|
||||
} catch (e) {
|
||||
console.error('Failed to get mic for preview:', e);
|
||||
}
|
||||
} else if (window.voiceHandler && window.voiceHandler.localStream) {
|
||||
window.voiceHandler.setupVOX();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1408,6 +1411,11 @@ async function handleSaveUserSettings(btn) {
|
||||
if (result.success) {
|
||||
btn.innerHTML = '<i class="fa-solid fa-check me-2"></i> Saved!';
|
||||
|
||||
// Update current username in window
|
||||
if (formData.get('display_name')) {
|
||||
window.currentUsername = formData.get('display_name');
|
||||
}
|
||||
|
||||
// Update local voiceHandler settings without reload
|
||||
if (window.voiceHandler) {
|
||||
const mode = formData.get('voice_mode');
|
||||
|
||||
12
requests.log
12
requests.log
@ -606,3 +606,15 @@
|
||||
{"date":"2026-02-17 15:05:57","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"v","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
2026-02-17 15:06:05 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-17 15:06:09 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
{"date":"2026-02-17 15:07:56","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"v","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
{"date":"2026-02-17 15:08:11","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
2026-02-17 15:14:44 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-17 15:14:44 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-17 15:18:05 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-17 15:18:05 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-17 15:19:12 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
{"date":"2026-02-17 15:19:29","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
{"date":"2026-02-17 15:19:34","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
{"date":"2026-02-17 15:19:53","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true}
|
||||
2026-02-17 15:19:56 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-17 15:20:01 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user