如何在Angular2应用程序中使用MediaRecorder对象? [英] How can I use a MediaRecorder object in an Angular2 application?

查看:441
本文介绍了如何在Angular2应用程序中使用MediaRecorder对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个小型Angular2应用,我正在尝试使用MediaRecorder对象( https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder )如下:

I'm building a small Angular2 app and I'm trying to use a MediaRecorder object (https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder) like so:

var mediaRecorder = new MediaRecorder(stream);

但是,TypeScript告诉我它找不到名字'MediaRecorder'。我猜这是我的TypeScript配置,我直接从QuickStart指南中提取( https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html )。配置如下所示:

However, TypeScript is telling me it cannot find name 'MediaRecorder'. I'm guessing this is down to my TypeScript configuration which I pulled directly from the QuickStart guide (https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html). The configuration looks like this:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
  "compileOnSave": true
}

我见过网络上包含target:es6的各种配置或lib:es6以及其他模块commonjs,但我是新手,所以我不确定发生了什么。当我尝试更新这些值时,我会收到更多错误。

I've seen various configurations around the web that include "target: es6" or "lib: es6" and also ones with modules other that "commonjs" but I'm new to this so I'm not really sure what is going on. When I've tried updating these values I get more errors.

有谁知道我怎么能让它工作?

Does anyone know how I can get this to work?

推荐答案

您的编译器对 MediaRecorder 对象一无所知。

Your compiler doesn't know anything about the MediaRecorder object.

只需声明如下:

declare var MediaRecorder: any;

这篇关于如何在Angular2应用程序中使用MediaRecorder对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆