mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 08:41:37 +00:00
Fixed .NET reference
This commit is contained in:
parent
21d2de2614
commit
b59d120b9a
@ -30,13 +30,9 @@ window.scrollToBottom = function(element) {
|
|||||||
let mediaRecorder;
|
let mediaRecorder;
|
||||||
let actualRecordingMimeType;
|
let actualRecordingMimeType;
|
||||||
let changedMimeType = false;
|
let changedMimeType = false;
|
||||||
let dotnetReference = null;
|
|
||||||
|
|
||||||
window.audioRecorder = {
|
window.audioRecorder = {
|
||||||
start: async function (dotnetRef, desiredMimeTypes = []) {
|
start: async function (dotnetRef, desiredMimeTypes = []) {
|
||||||
// Store the .NET reference for callbacks:
|
|
||||||
dotnetReference = dotnetRef;
|
|
||||||
|
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
|
||||||
// When only one mime type is provided as a string, convert it to an array:
|
// When only one mime type is provided as a string, convert it to an array:
|
||||||
@ -96,7 +92,7 @@ window.audioRecorder = {
|
|||||||
const uint8Array = new Uint8Array(arrayBuffer);
|
const uint8Array = new Uint8Array(arrayBuffer);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await dotnetReference.invokeMethodAsync('OnAudioChunkReceived', uint8Array);
|
await dotnetRef.invokeMethodAsync('OnAudioChunkReceived', uint8Array);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error sending audio chunk to .NET:', error);
|
console.error('Error sending audio chunk to .NET:', error);
|
||||||
}
|
}
|
||||||
@ -121,9 +117,6 @@ window.audioRecorder = {
|
|||||||
mimeType: actualRecordingMimeType,
|
mimeType: actualRecordingMimeType,
|
||||||
changedMimeType: changedMimeType,
|
changedMimeType: changedMimeType,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear the .NET reference:
|
|
||||||
dotnetReference = null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Finally, stop the recording (which will actually trigger the onstop event):
|
// Finally, stop the recording (which will actually trigger the onstop event):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user