首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用recorder.js对象调用此函数".record()“?

如何使用recorder.js对象调用此函数".record()“?
EN

Stack Overflow用户
提问于 2020-07-04 23:09:38
回答 1查看 264关注 0票数 1

我有一个简单的aurelia.js应用程序,它应该使用recorder-js录制音频。

我正在使用一个名为"simple-recorderjs-demo“的github项目的代码来启动一个recorder-js记录器。它在他们的演示中工作得很好,这是现场https://addpipe.com/simple-recorderjs-demo/

但是在我创建的记录器对象上不存在函数".record()“。我怎么才能让它工作呢?

https://github.com/addpipe/simple-recorderjs-demo/blob/master/js/app.js

EN

回答 1

Stack Overflow用户

发布于 2020-07-05 13:29:10

第一种解决方案: app.html

代码语言:javascript
运行
复制
<template>
  <button click.trigger="startRecording()" id="recordButton">Record</button>
</template>

app.ts

代码语言:javascript
运行
复制
export class App {
  gumStream: any;
  rec: any;
  input: any;
  AudioContext = window.AudioContext;
  audioContext: AudioContext;
  startRecording(){
    // copy code from example here without dom elements refs
  }
}

第二种解决方案:

代码语言:javascript
运行
复制
  attached() {
    // all magic with dom/jquery plugins, etc here
    let recordButton = <HTMLButtonElement>document.getElementById("recordButton");
    recordButton.addEventListener("click", this.startRecording);
  }
  startRecording(){
    // code here
    // don't use native html elements(like document.getById('#id')) here
  }

更新添加示例https://gist.dumber.app/?gist=c04207dc496d5bb5a0344983497a7c18

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62730802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档