本文介绍了得到“未捕获(承诺):TypeError:Object(...)不是函数";来自Ionic原生VideoEditor插件的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个离子应用程序,用户可以在其中录制新视频.然后,我想将视频分成帧并将帧发送到服务器.我正在使用ionic-native VideoEditor插件中的createThumbnail函数.但是当我尝试调用createThumbnail函数时,它会抛出

I'm developing an ionic app, where user can record a new video. Then I want to break the video into frames and send frames to a server. I'm using createThumbnail function from ionic-native VideoEditor plugin. But when I try to call createThumbnail function, it throws

这是我的源代码.

<ion-content padding>
  <button ion-button full (click)="captureVideo()">Capture video</button>
  <br/>
  <ion-list>
    <ion-item *ngFor="let file of mediaFiles" tappable (click)="playFile(file)" text-wrap>
      {{file.name}}
      <p>{{file.size/1000/1000 | number}} MB</p>
    </ion-item>
  </ion-list>
  <video controls autoplay #myvideo></video>
</ion-content>

TypeScript代码

captureVideo() {
    let options: CaptureVideoOptions = {
      limit: 1,
      duration: 30
    }
    this.mediaCapture.captureVideo(options).then((res: MediaFile[]) => {

      let videoData = JSON.stringify(res);
      let res1 = JSON.parse(videoData);
      this.videoURL = res1[0]['fullPath'];

      let video = this.myvideo.nativeElement;
      video.src =  this.videoURL;
      video.play();

      var option: CreateThumbnailOptions = {
        fileUri: res[0].fullPath,
        outputFileName: 'aaaa',
        atTime: 2,
        width: 320,
        height: 480,
        quality: 100
      };
      console.log("option :" ,option);
      this.videoEditor.createThumbnail(option).then(res=>{
        console.log('Thumbnail result: ' + res);
      }).catch(err=>{
        console.log("ERROR ERROR", err)
      });

    }, (err) => {
      console.log("ERROR", "error selecting video");
    });
  }

有人可以帮我吗,为什么我会出现这样的错误?

Can someone help me with, why I'm getting such error?

推荐答案

似乎ionic团队已对其本地插件进行了一些更改.您需要安装与您的项目类型相对应的正确版本的本机插件.并根据您的角度版本正确导入.您需要做的就是

It seems ionic team has made some changes to their native plugins. You need to install the correct version of the native plugin corresponding to your project type. And import it correctly based on your angular version. All you need to do is,

ionic.config.json 文件中检查您的项目类型.

Check your project type in ionic.config.json file.

如果类型为"离子角",则安装4.x.x版本.就您而言

If the type is "ionic-angular", then install 4.x.x version. In your case

npm i -s @ionic-native/[email protected]

如果类型为"角度",则安装5.x.x-beta版本

If the type is "angular", then install 5.x.x-beta version

npm i -s @ionic-native/[email protected]

注意:

仅当您使用Angular 6时,才在导入末尾添加ngx

Add ngx at the end of import only if you are using Angular 6

import { VideoEditor } from '@ionic-native/video-editor/ngx';

如果未同时从app.module.ts和app.component.ts中的导入中删除ngx

if not remove ngx from the import both in app.module.ts and app.component.ts

import { VideoEditor } from '@ionic-native/video-editor';

参考: https://github .com/ionic-team/ionic/issues/15225#issuecomment-414074074

这篇关于得到“未捕获(承诺):TypeError:Object(...)不是函数";来自Ionic原生VideoEditor插件的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:26