提交 f824e655 编写于 作者: Z zklth

Thu Sep 21 11:28:01 CST 2023 inscode

上级 7a093d7e
run = "npm i && npm run dev" run = "npm i && npm run dev"
language = "node"
[deployment] [deployment]
build = "npm i && npm run build" build = "npm i && npm run build"
...@@ -8,3 +9,6 @@ run = "npm run preview" ...@@ -8,3 +9,6 @@ run = "npm run preview"
PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}"
XDG_CONFIG_HOME = "/root/.config" XDG_CONFIG_HOME = "/root/.config"
npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global"
[debugger]
program = "main.js"
...@@ -9,5 +9,45 @@ ...@@ -9,5 +9,45 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.js"></script> <script type="module" src="/src/main.js"></script>
<button id="recordButton">开始录音</button>
<audio id="recordingsList" controls></audio>
<script>
const recordButton = document.getElementById('recordButton');
const recordingsList = document.getElementById('recordingsList');
let chunks = [];
recordButton.addEventListener('click', () => {
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
const mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start();
mediaRecorder.addEventListener('dataavailable', event => {
chunks.push(event.data);
});
mediaRecorder.addEventListener('stop', () => {
const blob = new Blob(chunks);
chunks = [];
const audioURL = URL.createObjectURL(blob);
recordingsList.src = audioURL;
});
setTimeout(() => {
mediaRecorder.stop();
}, 5000);
});
});
</script>
</body> </body>
</html>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册