未捕获的无法加载内存初始化程序Mp3LameEncoder.min.js.mem

时间:2018-12-13 08:17:42

标签: javascript jquery asp.net lamemp3

我一直在从事一个项目,需要从MIC录制声音并将其上传到Web服务器。我想要这个.mp3格式。为此已通过this tutorial

在末尾使用demo可以正常工作,但是当我使用相同的编码和所有提供的文件时,它在本地主机和Web上向我显示错误。

未捕获的无法加载内存初始化程序Mp3LameEncoder.min.js.mem

我完全按照他们的要求工作,并在demo页上修改了代码,但没有用。

我正在ASP.NET C#中工作,并且使用Chrome作为我的用户代理。

我的文件结构是:

enter image description here

这是示例代码:

<script>
    (function () {
        var audioContext, gumStream, recorder, input, encodingType, encodeAfterRecord = true, startRecording, stopRecording;

        URL = window.URL || window.webkitURL;

        var AudioContext = window.AudioContext || window.webkitAudioContext;

        //window.AudioContext = window.AudioContext || window.webkitAudioContext;

        navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;


        startRecording = function () {
            var constraints = { audio: true, video: false };
            navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
                audioContext = new AudioContext();
                gumStream = stream;
                input = audioContext.createMediaStreamSource(stream);
                //input.connect(audioContext.destination);
                encodingType = 'mp3';
                recorder = new WebAudioRecorder(input, {
                    workerDir: '/vendors/_war/',
                    encoding: encodingType,
                    numChannels:2
                });

                recorder.onComplete = function (recorder, blob) {
                    createDownloadLink(blob, recorder.encoding);
                    alert('recording done');
                }

                recorder.setOptions({
                    timeLimit: 120,
                    encodeAfterRecord: encodeAfterRecord,
                    ogg:{ quality: 0.5},
                    mp3: { bitRate: 160 }
                });

                recorder.startRecording();
            }).catch(function (err) {
                alert('Exception: ' + err);
            });
        };

        stopRecording = function () {
            gumStream.getAudioTracks()[0].stop();
            recorder.finishRecording();
        };

        $('#recordButton').on('click', function () {
            startRecording();
        });
        $('#stopButton').on('click', function () {
            stopRecording(true);
        });
    }).call(this);
    function createDownloadLink(blob, encoding) {

        var url = URL.createObjectURL(blob);
        var au = $('#au'); //document.createElement('audio');
        //var li = document.createElement('li');
        //var link = document.createElement('a');

        //add controls to the &amp;amp;lt;audio&amp;amp;gt; element
        au.controls = true;
        au.src = url;

        //link the a element to the blob
        //link.href = url;
        //link.download = new Date().toISOString() + '.' + encoding;
        //link.innerHTML = link.download;

        //add the new audio and a elements to the li element
        //li.appendChild(au);
        //li.appendChild(link);

        //add the li element to the ordered list
        //var recordingsList = $('#recordingsList');
        //recordingsList.appendChild(li);
    }
</script>

1 个答案:

答案 0 :(得分:0)

对于我来说,我需要为.mem文件扩展名添加要用于Web配置的MIME类型:

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".mem" mimeType="text/html" />
    </staticContent>
</system.webServer>