mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-14 11:01:36 +00:00
Implemented sound effects
This commit is contained in:
parent
64e07f7702
commit
d7bfd52773
@ -33,9 +33,23 @@ let changedMimeType = false;
|
|||||||
let pendingChunkUploads = 0;
|
let pendingChunkUploads = 0;
|
||||||
|
|
||||||
window.audioRecorder = {
|
window.audioRecorder = {
|
||||||
|
playSound: function(soundPath) {
|
||||||
|
try {
|
||||||
|
const audio = new Audio(soundPath);
|
||||||
|
audio.play().catch(error => {
|
||||||
|
console.warn('Failed to play sound effect:', error);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Error creating audio element:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
start: async function (dotnetRef, desiredMimeTypes = []) {
|
start: async function (dotnetRef, desiredMimeTypes = []) {
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
|
||||||
|
// Play start recording sound effect:
|
||||||
|
this.playSound('/sounds/start_recording.ogg');
|
||||||
|
|
||||||
// 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:
|
||||||
if (typeof desiredMimeTypes === 'string') {
|
if (typeof desiredMimeTypes === 'string') {
|
||||||
desiredMimeTypes = [desiredMimeTypes];
|
desiredMimeTypes = [desiredMimeTypes];
|
||||||
@ -123,6 +137,9 @@ window.audioRecorder = {
|
|||||||
|
|
||||||
console.log('Audio recording - all chunks uploaded, finalizing.');
|
console.log('Audio recording - all chunks uploaded, finalizing.');
|
||||||
|
|
||||||
|
// Play stop recording sound effect:
|
||||||
|
window.audioRecorder.playSound('/sounds/stop_recording.ogg');
|
||||||
|
|
||||||
// Stop all tracks to release the microphone:
|
// Stop all tracks to release the microphone:
|
||||||
mediaRecorder.stream.getTracks().forEach(track => track.stop());
|
mediaRecorder.stream.getTracks().forEach(track => track.stop());
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user