yusitnikov / fix-webm-duration

navigator.mediaDevices.getUserMedia + MediaRecorder create WEBM files without duration metadata. This library appends missing metadata section right to the file blob.
MIT License
259 stars 50 forks source link

Package installed with NPM but 'ysFixWebmDuration' is not defined #5

Closed JorViteri closed 3 years ago

JorViteri commented 3 years ago

Hi, I installed the package with the command:

npm i fix-webm-duration

As It's indicated in this website.

When I try to use the function 'ysFixWebmDuration' the function appears underlined in red with the error message: '"ysFixWebmDuration" is not defined'.

I am using the function in the following code:

this.mediaRecorder.onstop = (event) => {
        console.log('Recorder stopped: ', event);        
        var duration = Date.now() - this.startTime;
        var buggyBlob = new Blob(this.recordedBlobs, { type: 'video/webm' });
        ysFixWebmDuration(buggyBlob, duration, function(fixedBlob) {
          this.fixedBlob = fixedBlob;
        });
      };

npm list shows that the package is installed.

I'm a bit of a noob with Vue and MediaRecorder, Did I miss a step? Thank you for your time.

jannisbecker commented 3 years ago

You have to add an import statement to be able to use it. Usually you would write that somewhere at the top of your file: import ysFixWebmDuration from "fix-webm-duration";

Depending on your setup, it could also be: const ysFixWebmDuration = require("fix-webm-duration");

but the former worked for me.

JorViteri commented 3 years ago

You have to add an import statement to be able to use it. Usually you would write that somewhere at the top of your file: import ysFixWebmDuration from "fix-webm-duration";

Depending on your setup, it could also be: const ysFixWebmDuration = require("fix-webm-duration");

but the former worked for me.

Thank you! that fixed my problem