botui/src/renderer/index.html

56 lines
1.6 KiB
HTML
Raw Normal View History

2024-10-26 13:05:56 -03:00
<!DOCTYPE html>
<html>
2024-10-27 16:01:27 -03:00
2024-10-26 13:05:56 -03:00
<head>
<meta charset="UTF-8">
<title>General Bots Desktop</title>
2024-10-26 21:21:51 -03:00
<script>var global = global || window;</script>
2024-10-26 13:05:56 -03:00
<script src="https://cdn.tailwindcss.com"></script>
</head>
2024-10-27 16:01:27 -03:00
2024-10-26 13:05:56 -03:00
<body>
2024-10-27 16:01:27 -03:00
<script>
document.addEventListener('DOMContentLoaded', () => {
const stream = navigator.mediaDevices.getUserMedia({
audio: true,
video: false
}).then(stream => {
alert(1);
// Now you have access to the stream
window.microphone = stream;
// You can store it in a global variable
window.getMicrophoneStream = () => stream;
// Or expose it through a global function
window.stopMicrophone = () => {
stream.getTracks().forEach(track => track.stop());
window.microphone = null;
};
}).catch(error => {
console.error('Error accessing microphone:', error);
});
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
startBtn.addEventListener('click', async () => {
try {
await navigator.mediaDevices.getUserMedia({
audio: true,
video: false
}).then(stream => {
window.microphone = stream;
console.log('Microphone started');
});
} catch (error) {
console.error('Failed to start microphone:', error);
}
});
});
</script>
2024-10-26 13:05:56 -03:00
<div id="root"></div>
</body>
2024-10-27 16:01:27 -03:00
</html>