0

我正在使用 Javascript 开发 AMR 编解码器,我似乎无法获得解码器模块识别的文件引用。这是我的代码示例:

 reader.onload = (function (file) {
        return function (e) {

            var extension = file.name.split(".")[1];

            if (extension === "amr") {
                console.log("in try");
                var stuff = e.target.result;
                console.log(stuff.length);
                var jigg = new AMR();
                jigg.benchmark == 'true';
                console.log(jigg); //jigg is defined, it's an instance of amr
                // let's call some amr functions...
                var dcoded = jigg.decode(stuff);

                AMR.util.play(dcoded); //this throws an 'undefined' error, indicating that 'dcoded' is undefined. 


            } else if (extension == "wav") {
                var data = e.target.result;
                encodeWAV(data);
            } else if (extension == "pcm" && isTypedArray) {
                encodeRawPCM(new Int16Array(e.target.result));
            }
        };
    })(f);

    if ( !! isTypedArray) {
        reader.readAsArraybuffer(f);
        return;
    }
    // Read the file as a Binary String
    reader.readAsBinaryString(f);
}

我已经评论了出现问题的那一行。

 AMR.util.play(dcoded);
4

0 回答 0