Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the plugin with Angular 4 in my Ionic 3 project? #68

Closed
IgorSamer opened this issue Jun 29, 2018 · 1 comment
Closed

How can I use the plugin with Angular 4 in my Ionic 3 project? #68

IgorSamer opened this issue Jun 29, 2018 · 1 comment
Labels

Comments

@IgorSamer
Copy link

IgorSamer commented Jun 29, 2018

I already installed the plugins videojs-wavesurfer (npm install videojs-wavesurfer --save) and wavesurfer.js (npm install wavesurfer.js --save) and now I want to use them in my Ionic 3 component.

I was working only with Video.js, and all it working fine. But now, I need to add videojs-wavesurfer plugin.

I tried:

Component.html:

<audio class="video-js vjs-default-skin" controls #audio>
    <source [src]="audioSource" type="audio/mp3">
</audio>

Component.ts:

import videojs from 'video.js';
import WaveSurfer from 'wavesurfer.js';
import VideojsWavesurfer from 'videojs-wavesurfer';

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 Error: plugin "wavesurfer" does not exist

So, I changed the code to:

import videojs from 'video.js';
import WaveSurfer from 'wavesurfer.js';
import VideojsWavesurfer from 'videojs-wavesurfer';

let audioJS = videojs(this.audio,
    {
      fluid: true,
      plugins: {
        VideojsWavesurfer
      }
    }, () => {

    });

And apparently recognized the plugin, but now I get this error:

Uncaught Error: Cannot find module "WaveSurfer"

How can I fix it?

@IgorSamer IgorSamer changed the title How can I use the plugin with Angular 4 in my Ionic 3 project How can I use the plugin with Angular 4 in my Ionic 3 project? Jun 29, 2018
@thijstriemstra
Copy link
Member

Sorry for the late reply @IgorSamer. Take a look at https://github.com/collab-project/videojs-wavesurfer/wiki/Webpack

I would change your imports to:

import videojs from 'video.js';
import WaveSurfer from 'wavesurfer.js';

/*
// this is only required when you're using the videojs-wavesurfer 'live' mode
// with the microphone plugin
import MicrophonePlugin from 'wavesurfer.js/dist/plugin/wavesurfer.microphone.js';
WaveSurfer.microphone = MicrophonePlugin;
*/

// register videojs-wavesurfer plugin with this import
import Wavesurfer from 'videojs-wavesurfer/dist/videojs.wavesurfer.js';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants