mirror of
https://github.com/duckietm/Nitro-Cool-UI.git
synced 2025-06-21 22:36:58 +00:00
Start: working on Chat
This commit is contained in:
parent
606f8145f8
commit
355284bbf4
@ -26,6 +26,7 @@
|
||||
"game.center.enabled": false,
|
||||
"guides.enabled": true,
|
||||
"toolbar.hide.quests": true,
|
||||
"api.sound.upload": "/chatvoice/upload.php",
|
||||
"navigator.room.models": [
|
||||
{ "clubLevel": 0, "tileSize": 104, "name": "a" },
|
||||
{ "clubLevel": 0, "tileSize": 94, "name": "b" },
|
||||
|
@ -29,14 +29,14 @@ export const ChatInputView: FC<{}> = props =>
|
||||
|
||||
var deletedAudio = false;
|
||||
|
||||
function startRecording(){
|
||||
|
||||
function startRecording() {
|
||||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
||||
microphoneOn.style.display = "none";
|
||||
microphoneOff.style.display = "inline-block";
|
||||
deleteAudio.style.display = "inline-block";
|
||||
|
||||
navigator.mediaDevices.getUserMedia({audio:true})
|
||||
.then(stream=> {
|
||||
|
||||
navigator.mediaDevices.getUserMedia({ audio: true })
|
||||
.then(stream => {
|
||||
mediaRecorder = new MediaRecorder(stream);
|
||||
mediaRecorder.start();
|
||||
|
||||
@ -49,23 +49,27 @@ export const ChatInputView: FC<{}> = props =>
|
||||
microphoneOff.style.display = "none";
|
||||
deleteAudio.style.display = "none";
|
||||
|
||||
if(!deletedAudio){
|
||||
if (!deletedAudio) {
|
||||
const audioBlob = new Blob(audioChunks);
|
||||
var fd = new FormData();
|
||||
fd.append("audio", audioBlob);
|
||||
fetch("https://int.habbeh.net/audio.php", {method:"POST", body: fd})
|
||||
.then((response) => response.text())
|
||||
.then((resp) => {
|
||||
roomSession.sendChatMessage("https://int.habbeh.net/audios/" + resp + ".mp3",0);
|
||||
})
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append("audio", audioBlob);
|
||||
fetch(GetConfiguration<string>('api.sound.url'), { method: "POST", body: fd })
|
||||
.then((response) => response.text())
|
||||
.then((resp) => {
|
||||
roomSession.sendChatMessage(GetConfiguration<string>('api.sound.upload') + resp + ".mp3", 0);
|
||||
})
|
||||
}
|
||||
|
||||
deletedAudio = false;
|
||||
audioChunks = [];
|
||||
});
|
||||
})
|
||||
}
|
||||
.catch(error => {
|
||||
console.error('Error accessing microphone:', error);
|
||||
});
|
||||
} else {
|
||||
console.error('getUserMedia is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
function stopRecording(){
|
||||
microphoneOn.style.display = "inline-block";
|
||||
|
Loading…
x
Reference in New Issue
Block a user