首页 > 解决方案 > TypeError:无法读取未定义的属性“getUserMedia”

问题描述

我想在生产环境中的 Angular 应用程序中使用记录器服务。我使用 Angular 7。我想使用我的 IP 地址而不是 localhost 访问服务器。

我尝试使用与开发环境完美配合并使用 localhost 的代码,它使用 chrome 浏览器工作。

import {Component} from '@angular/core';
import MicRecorder from 'mic-recorder-to-mp3';

@Component({
  selector: 'app-recorder',
  templateUrl: './recorder.component.html',
  styleUrls: ['./recorder.component.scss']
})
export class RecorderComponent {

  recorder = new MicRecorder({
    bitRate: 128,
    audio: true,

  });

  constructor() {

  }

  start() {
      this.recorder.start().then(() => {

      }).catch((e) => {
        console.error(e);
      });

  }

我在生产环境中使用相同的代码并使用 IP 地址而不是 localhost 时出现此错误

TypeError: Cannot read property 'getUserMedia' of undefined

标签: angular7

解决方案


推荐阅读