首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有人把视频记录和角7集成在一起?

有没有人把视频记录和角7集成在一起?
EN

Stack Overflow用户
提问于 2019-04-24 14:48:11
回答 2查看 3.8K关注 0票数 2

我试图用视频录制视频,我的应用程序是角7,我跟踪了他们的wiki。下面是https://github.com/collab-project/videojs-record/wiki/Angular下面的链接,但这对我不起作用。

这是我所得到的错误

代码语言:javascript
复制
ERROR in ./node_modules/videojs-record/dist/videojs.record.js
Module not found: Error: Can't resolve 'RecordRTC' in '/path/to/project/root/node_modules/videojs-record/dist'
ERROR in ./node_modules/videojs-record/dist/videojs.record.js
Module not found: Error: Can't resolve 'videojs' in '/path/to/project/root/node_modules/videojs-record/dist'

这是我的代码和我的视频is在视频记录器.组件中的配置

代码语言:javascript
复制
import { Component, OnInit, OnDestroy, ElementRef, Input } from '@angular/core';
import videojs from 'video.js';
import * as adapter from 'webrtc-adapter/out/adapter_no_global.js';
import * as RecordRTC from 'recordrtc';

// register videojs-record plugin with this import
import * as Record from 'videojs-record/dist/videojs.record.js';

@Component({
  selector: 'app-video-recorder',
  templateUrl: './video-recorder.component.html',
  styleUrls: ['./video-recorder.component.scss']
})
export class VideoRecorderComponent implements OnInit, OnDestroy {
  // reference to the element itself: used to access events and methods
  private _elementRef: ElementRef;

  // index to create unique ID for component
  @Input() idx: string;

  private config: any;
  private player: any; 
  private plugin: any;

  // constructor initializes our declared vars
  constructor(elementRef: ElementRef) {
    this.player = false;

    // save reference to plugin (so it initializes)
    this.plugin = Record;

    // video.js configuration
    this.config = {
      controls: true,
      autoplay: false,
      fluid: false,
      loop: false,
      width: 320,
      height: 240,
      controlBar: {
        volumePanel: false
      },
      plugins: {
        // configure videojs-record plugin
        record: {
          audio: false,
          video: true,
          debug: true
        }
      }
    };
  }

  ngOnInit() {}

  // use ngAfterViewInit to make sure we initialize the videojs element
  // after the component template itself has been rendered
  ngAfterViewInit() {
    // ID with which to access the template's video element
    let el = 'video_' + this.idx;

    // setup the player via the unique element ID
    this.player = videojs(document.getElementById(el), this.config, () => {
      console.log('player ready! id:', el);

      // print version information at startup
      var msg = 'Using video.js ' + videojs.VERSION +
        ' with videojs-record ' + videojs.getPluginVersion('record') +
        ' and recordrtc ' + RecordRTC.version;
      videojs.log(msg);
    });

    // device is ready
    this.player.on('deviceReady', () => {
      console.log('device is ready!');
    });

    // user clicked the record button and started recording
    this.player.on('startRecord', () => {
      console.log('started recording!');
    });

    // user completed recording and stream is available
    this.player.on('finishRecord', () => {
      // recordedData is a blob object containing the recorded data that
      // can be downloaded by the user, stored on server etc.
      console.log('finished recording: ', this.player.recordedData);
    });

    // error handling
    this.player.on('error', (element, error) => {
      console.warn(error);
    });

    this.player.on('deviceError', () => {
      console.error('device error:', this.player.deviceErrorCode);
    });
  }

  // use ngOnDestroy to detach event handlers and remove the player
  ngOnDestroy() {
    if (this.player) {
      this.player.dispose();
      this.player = false;
    }
  }

}

这是我的视频录音机。

代码语言:javascript
复制
<video id="video_{{idx}}" class="video-js vjs-default-skin" playsinline></video>

下面的信息可能有助于解决这个问题。

代码语言:javascript
复制
Angular CLI: 7.2.3
Node: 10.15.1
OS: linux x64
Angular: 7.2.2
... common, compiler, core, forms, language-service
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.3
@angular-devkit/build-angular     0.12.3
@angular-devkit/build-optimizer   0.12.3
@angular-devkit/build-webpack     0.12.3
@angular-devkit/core              7.2.3
@angular-devkit/schematics        7.2.3
@angular/animations               7.2.7
@angular/cdk                      7.3.0
@angular/cli                      7.2.3
@angular/compiler-cli             7.2.7
@ngtools/webpack                  7.2.3
@schematics/angular               7.2.3
@schematics/update                0.12.3
rxjs                              6.3.3
typescript                        3.2.4

我对角质很陌生。因此,在这方面的任何帮助都将不胜感激。提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-04-25 16:35:43

不用担心,伙计们,我自己修好了。在做了一些研究之后,我了解到,由于我使用角cli来服务和构建,所以我使用了ngx- (因为ng eject在角7中被废弃,并将从角8中删除)来使用角cli执行webpack配置。这个webpack的配置之前就不见了。这可能会帮助到某个人,这就是为什么要分享的原因。谢谢。

票数 1
EN

Stack Overflow用户

发布于 2019-05-07 12:01:51

你不能那样用。如果您使用角cli服务或构建,那么您必须创建一个部分webpack配置文件,并服务或构建它通过角cli。你应该跟随下面的事情。

请访问下面的链接和安装软件包,并按照指示配置您的人员。

https://www.npmjs.com/package/ngx-build-plus

你的webpack.partial.js应该看起来像

代码语言:javascript
复制
const webpack = require('webpack');

module.exports = {
    resolve: {
        alias: {
            // place your config
        }
    },
    plugins: [
        // place your config
    ],

}

scriptspackage.json文件中应该看起来像

代码语言:javascript
复制
"scripts": {
    "ng": "ng",
    "start": "ng serve --extra-webpack-config webpack.partial.js",
    "build": "ng build --extra-webpack-config webpack.partial.js",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:prod": "ng build --prod --extra-webpack-config webpack.partial.js",
    "build:stage": "ng build --prod -c staging --extra-webpack-config webpack.partial.js",
    "build:dev": "ng build -c development --extra-webpack-config webpack.partial.js"
  },

然后,您可以使用npm start为您的应用程序提供服务,构建您可以使用基于环境的npm run build:dev财政报告(npm run build:dev)\。

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

https://stackoverflow.com/questions/55832898

复制
相关文章

相似问题

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