I'm using Video.js in my Ionic 3 app for videos and audios, and all works fine. But now, I want to use the Video.js Wavesufer plugin for audios.
I installed the plugin via npm:
npm install videojs-wavesurfer --save (plugin)
npm install wavesurfer.js --save (dependency)
And imported them in my component.ts:
import WaveSurfer from 'wavesurfer.js';
import VideojsWavesurfer from 'videojs-wavesurfer';
And I called videojs
function to init the player:
ngAfterViewInit() {
if (this.audio) {
this.audio = this.audio.nativeElement;
let audioJS = videojs(this.audio,
{
fluid: true,
plugins: {
wavesurfer: {
src: this.audioSource,
msDisplayMax: 10,
debug: true,
waveColor: 'grey',
progressColor: 'black',
cursorColor: 'black',
hideScrollbar: true
}
}
}, () => { }
);
}
}
But console prints the following error:
Error: plugin "wavesurfer" does not exist.
So, I changed the object to:
fluid: true,
plugins: { VideojsWavesurfer }
And apparently recognized the plugin, but now I get this error (I said that apparently it recognized the plugin because this error came from videojs.wavesurfer.min.js
):
Uncaught Error: Cannot find module "WaveSurfer"
I've already tried to add WaveSurfer
to imports on app.components.ts
but nothing changes. So, how can I fix it?