简体   繁体   English

使WaveSurfer.js在Ionic 3中工作

[英]Getting WaveSurfer.js to work in Ionic 3

I am trying to embed WaveSurfer.js in an Ionic 3 app. 我正在尝试将WaveSurfer.js嵌入Ionic 3应用程序中。

I tried including the CDN script into the index file and accessing the WaveSurfer variable in the root page constructor. 我尝试将CDN脚本包含到索引文件中,并在根页构造函数中访问WaveSurfer变量。

index.html 的index.html

<script src="//cdnjs.cloudflare.com/ajax/libs/wavesurfer.js/1.3.7/wavesurfer.min.js"></script>

home.ts home.ts

export class HomePage {
    constructor(public navCtrl: NavController) {

        var wavesurfer = WaveSurfer.create({
            container: '#waveform',
            waveColor: 'violet',
            progressColor: 'purple'
        });
    }
}

I also tried access this variable through the global window variable (I know this is horrible practice, but I am just building a proof of concept for now) 我也尝试通过全局窗口变量访问此变量(我知道这是很糟糕的做法,但是我现在只是在构建概念证明)

let wavesurfer = window['WaveSurfer'];

The WaveSurfer plugin recently started supporting ES6 and think this is a cleaner integration but since I am new to Ionic/Angular I am having problems getting this to work as well. WaveSurfer插件最近开始支持ES6,并认为这是一种更干净的集成,但是由于我是Ionic / Angular的新手,所以在使它也正常工作方面存在问题。

Yeah, use ES6 是的,使用ES6

npm install --save wavesurfer.js@2.0.0-beta01

then, in your component 然后,在您的组件中

import WaveSurfer from 'wavesurfer.js';

follow this issue on github for an example 在github上关注此问题为例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM