lamejs无法与angular 8一起使用-未捕获ReferenceError:未定义Lame

问题描述

我在package.json中添加了“ lamejs”:“ ^ 1.2.0”,然后在app.component.ts中添加了以下几行:

var lamejs = require("lamejs");
    let channels = 1; //1 for mono or 2 for stereo
    let sampleRate = 44100; //44.1khz (normal mp3 samplerate)
    let kbps = 128; //encode 128kbps mp3
    let mp3encoder = new lamejs.Mp3Encoder(channels,sampleRate,kbps);
    var mp3Data = [];

    let samples = new Int16Array(44100); //one second of silence (get your data from the source you have)
    let sampleBlockSize = 1152; //can be anything but make it a multiple of 576 to make encoders life easier

    var mp3Data = [];
    let sampleChunk;
    for (var i = 0; i < samples.length; i += sampleBlockSize) {
        sampleChunk = samples.subarray(i,i + sampleBlockSize);
        var mp3buf = mp3encoder.encodeBuffer(sampleChunk);
        if (mp3buf.length > 0) {
            mp3Data.push(mp3buf);
        }
    }
    var mp3buf = mp3encoder.flush();   //finish writing mp3

    if (mp3buf.length > 0) {
        mp3Data.push(new `Int8Array(mp3buf));`
    }

    var blob = new Blob(mp3Data,{ type: 'audio/mp3' });
    var url = window.URL.createObjectURL(blob);
    console.log('MP3 URl: ',url);

我在控制台中收到此错误, index.js:17未捕获的ReferenceError:未定义me脚 在Object ../ node_modules / lamejs / src / js / index.js

当我在该行打开此index.js时,我看到Lame = require('./ Lame.js');

使用了相同的变量而没有声明,我该如何进行操作,我一直在解决声明问题的这类错误,但是列表只是不断出现。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)