问题描述
我有一个带有嵌入式音频记录器的简单HTML Web元素。我希望记录器在加载后自动开始记录。我遇到了一些非常奇怪的行为,当我重新编译应用程序时录音会起作用,否则就不会。如果在应用程序的已编译版本上刷新页面,则会得到一个空的记录缓冲区。
这是我的代码的关键部分:
const MicRecorder = require("mic-recorder-to-mp3");
...
class Microphone extends HTMLElement {
constructor() {
super();
// Add a shadow DOM
const shadowDOM = this.attachShadow({ mode: "open" });
this.shadowDOM = shadowDOM;
// Render
this.shadowDOM.appendChild(template.content.cloneNode(true));
...
// Bind methods
this.toggleRecord = this.toggleRecord.bind(this);
}
connectedCallback() {
if (this.startRecording) {
this.toggleRecord();
}
}
toggleRecord() {
const recordButton = this.shadowRoot.querySelector("#record-button");
if (this.isRecording()) {
this.recorder
.stop()
.getMp3()
.then(([buffer,blob]) => {...})
} else {
this.recorder
.start()
.then(() => {...})
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)