Start: working on Chat

This commit is contained in:
duckietm 2024-03-15 10:23:33 +01:00
parent 606f8145f8
commit 355284bbf4
2 changed files with 21 additions and 16 deletions

View File

@ -26,6 +26,7 @@
"game.center.enabled": false, "game.center.enabled": false,
"guides.enabled": true, "guides.enabled": true,
"toolbar.hide.quests": true, "toolbar.hide.quests": true,
"api.sound.upload": "/chatvoice/upload.php",
"navigator.room.models": [ "navigator.room.models": [
{ "clubLevel": 0, "tileSize": 104, "name": "a" }, { "clubLevel": 0, "tileSize": 104, "name": "a" },
{ "clubLevel": 0, "tileSize": 94, "name": "b" }, { "clubLevel": 0, "tileSize": 94, "name": "b" },

View File

@ -30,7 +30,7 @@ export const ChatInputView: FC<{}> = props =>
var deletedAudio = false; var deletedAudio = false;
function startRecording() { function startRecording() {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
microphoneOn.style.display = "none"; microphoneOn.style.display = "none";
microphoneOff.style.display = "inline-block"; microphoneOff.style.display = "inline-block";
deleteAudio.style.display = "inline-block"; deleteAudio.style.display = "inline-block";
@ -53,18 +53,22 @@ export const ChatInputView: FC<{}> = props =>
const audioBlob = new Blob(audioChunks); const audioBlob = new Blob(audioChunks);
var fd = new FormData(); var fd = new FormData();
fd.append("audio", audioBlob); fd.append("audio", audioBlob);
fetch("https://int.habbeh.net/audio.php", {method:"POST", body: fd}) fetch(GetConfiguration<string>('api.sound.url'), { method: "POST", body: fd })
.then((response) => response.text()) .then((response) => response.text())
.then((resp) => { .then((resp) => {
roomSession.sendChatMessage("https://int.habbeh.net/audios/" + resp + ".mp3",0); roomSession.sendChatMessage(GetConfiguration<string>('api.sound.upload') + resp + ".mp3", 0);
}) })
} }
deletedAudio = false; deletedAudio = false;
audioChunks = []; audioChunks = [];
}); });
}) })
.catch(error => {
console.error('Error accessing microphone:', error);
});
} else {
console.error('getUserMedia is not supported');
}
} }
function stopRecording(){ function stopRecording(){