1. 程式人生 > >實現base64格式的amr音訊檔案在IOS、android微信內建瀏覽器的播放

實現base64格式的amr音訊檔案在IOS、android微信內建瀏覽器的播放

參考文件:

1.https://github.com/yxl/opencore-amr-js   (將amr檔案轉為wav格式的編解碼專案)

因為專案需要,要將amr的base46格式的音訊檔案在IOS,android微信內建瀏覽器播放。專案中使用的第三方IM為融雲,經過調研發現,使用融雲js播放語音的方式,可以在IOS上播放,但是在Android上無法播放,而且h5的audio元件,不支援amr格式的音訊檔案。

最後得出的結論,IOS上的audio支援amr格式播放,android上audio元件不支援amr格式播放,包括使用融雲js播放語音的方式,使用的也是audio元件。

想到的方案是,將amr的base64檔案進行格式轉換,轉換為mp3,wav等audio支援的格式,然後進行播放,沒有找到很好的資源。

經過領導的一句話,嘗試性的找融雲客服諮詢了一下,看看有沒有相關的專案,客服給了opencore-amr-js專案,是將amr格式的檔案轉換為wav格式的音訊檔案,進行播放。

將專案釋出到測試環境,在微信內建瀏覽器跑了一下,得到的答案是,android可以正常播放,但是IOS無法播放;其中有一個物件,在IOS環境中,好像是找不到,執行就報錯。

於是,綜合了一下,得到了最終的解決方案,

IOS使用融雲js進行語音播放,Android使用opencore-amr-js進行語音播放;播放語音時,判斷機器為Android還是IOS,來選擇播放方式。

在將opencore-amr-js專案往自己專案遷移的過程中,發現,融雲js中使用的Libamr-2.2.5.min.js

 檔案,就是opencore-amr-js專案中的amrnb.js檔案,也就是說,融雲js也是在  opencore-amr-js專案的基礎上開發的,而且改動也非常小,Android中需要使用的方法,都沒有發生變動,感覺還是挺開心的,因為amrnb.js檔案有474kb,太大了,如果在加上融雲js的Libamr-2.2.5.min.js 檔案,整個聊天室,得有1兆多了,載入時間太長了。

下面,將Android播放語音的程式碼放在下面:

demo下載地址,demo在專案的js目錄下面。

<!DOCTYPE html>

<html>
<head>
    <title>AMR decode/encode tests</title>
    <script src="amrnb.js" defer></script>
</head>

<body>
<h2>Test decoder</h2>
<p id="test">
    Convert <a href="yuan.amr">yuan.amr</a> to wav file and compare with <a href="yuan.wav">yuan.wav</a>:
    <button>Test</button>
</p>
<h2>Decode amr file and play</h2>
<p id="sample-amr">
    <button>Play</button>
    <a href="yuan.amr">yuan.amr</a>
</p>
<p>
    Select a local file and play: <input type="file" id="amr-file" accept=".amr">
</p>
<h2>Encode audio to amr file and play</h2>
<p id="sample-audio">
    <button>Encode & Play</button>
    <a href="hello.ogg">hello.ogg</a>
</p>
<p>
    Select a local file to encode and play: <input type="file" id="audio-file" accept="audio/*">
</p>
<h2>base64測試</h2>
<input id="base64-input" type="text" style="width:800px;height: 200px;">
<p id="base64-audio">
    <button>base64 & Play</button>
</p>
<p id="base64-audio2">
    <button>base64 & Play</button>
</p>
<p id="base64-audio3">
    <button>base64 & Play</button>
</p>
<p id="base64-audio4">
    <button>base64 & Play</button>
</p>
<p id="base64-audio5">
    <button>base64 & Play</button>
</p>


<h2>Amr to wav</h2>
<p id="amr-to-wav">
    <button>Convert to wav and play</button>
    <a href="yuan.amr">yuan.amr</a>
</p>
<p>
    Select a local file, convert and play: <input type="file" id="amr-to-wav-file" accept=".amr">
</p>
<p>wav file content:</p>
<pre></pre>
<script>

    //    var u = navigator.userAgent;
    //    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android終端
    //    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
    //    alert('是否是Android:'+isAndroid);
    //    alert('是否是iOS:'+isiOS);

    function E(selector) {
        return document.querySelector(selector);
    }

    E('#test > button').onclick = function () {
        fetchAndReadBlob('yuan.amr', function (amr) {
            fetchAndReadBlob('yuan.wav', function (expected) {
                var actual = AMR.toWAV(amr);
                if (actual == null) {
                    alert('Failed to decode amr file.');
                    return;
                }
                if (actual.length != expected.length) {
                    alert('The converted wav file has different size.');
                    return;
                }
                for (var i = 0; i < actual.length; i++) {
                    if (actual[i] != expected[i]) {
                        alert('The converted wav file has different content.');
                        return;
                    }
                }
                alert('Succeeded!');
            });
        });
    };

    E('#sample-amr > button').onclick = function () {
        fetchBlob(E('#sample-amr > a').href, function (blob) {
            playAmrBlob(blob);
        });
    };

    E('#amr-file').onchange = function () {
        playAmrBlob(this.files[0]);
    };

    E('#amr-to-wav > button').onclick = function () {
        fetchBlob(E('#amr-to-wav > a').href, function (blob) {
            convertAmrBlobToWav(blob);
        });
    };

    E('#amr-to-wav-file').onchange = function () {
        convertAmrBlobToWav(this.files[0]);
    };

    E('#sample-audio > button').onclick = function () {
        fetchBlob(E('#sample-audio > a').href, function (blob) {
            convertAudioBlobToAmr(blob);
        });
    };

    E('#base64-audio > button').onclick = function () {
        playAmrToWav('IyFBTVIKLEWGYIDYAbvFOH2GfsiOIegRLMIqLEkrjgtAHkTQivDmfVM1jaNZEngILE2GwAPEmHx5NDk7pUNLUfWYUsHoLEgkjgtMXPPQwhrzXi7BBeVsCTl8LCwkwAeF+DQZtU6aHy/oi85xm48+LEQZTg8IfgSxFs8MTWkmTJnCiVeQLAmWQA8DcwJqRyWK6D1JXNiGT1/kLCCtjhwg/i4HQxYBTh/FyL0c4PKGLEOUnB8ECWzBtivj/o0uCKBOSVwaLERviBwjOO1SQyDHHShqp6v5ntQ6LIK0jpaN20m16Ebxbex+FST/0L6cLESbnFiime8ELtBDikj7R/v6kpIGLJAYHB7i/IW3MtgZjH8HkdlbX+rQLENADj2QDXL1/KDsHpJRFQkItcEKLJA/slqjGeHpl6LdmIvkg+s3mzP6LGgYHB9gmUS7M7dqXkMDBu1gS3xCLE8Rhw5pGcJiYMXkGiFCKV12SAZSLEwYsh+gnLQ+jtRY/HnRKOJ9ze1kLGiksh/A3DJFpp97NdhcYOKEjY5wLEzDnJdhDXHBDiasPfK6kXn+4t5mLE7bjh9gmT5rYfVsrppPiaj1HjgMLE1TnB9APIbLx4jNHneWgW2iXYYqLE5vjhfiHD5ogLu4T3Qa1UbBahXaLEBHsh6D2gTTLIciRh0Tpc+iVlQILEXtmh8COJcs4kOVfNmoU5JsVakWLEPtnBygeMf3F/mGHbA4xUxe72hsLC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k1ILExHsh4JWJcFQhJ3G41WLeLxbOKELE8qvA8BFAh7Ayu/n3/QC3K6RziALGKjUBaQuYJNIf5SNlefkelZXdHKLEy0vBtJmTNtYwes7vyXUdPSa1IILClTUBwgSGp6STlsv9t2gH+kDWbALB4PvB0gABKm+hImnwV8APqdZESqLB4IvBwiYBAhMgCdOI3iAuM0M/bcLCnCvB4QkfzIOj5Yftvqne8ThXnaLBsyTh4AUxcAN1m1NHPfErnshny2LDCBjgtRngH0Uyp4vUqxCedYHn90LCgMtBhiCgXGoodefNWyYaHqE1/GLFHvwBxs1jRSisWI+Vp6yeSdnGcuLGLBNB6SAOpfVpFSl0N7MXVJmqayLGPvjB6wCd4Q9vtkrtWPMiiRFjsCLGPvOB4Qg3veV9o4e2WWCbLSuk8ELGOECB6KEKtFRBGWUxK3LevJNWNsLDj1Qg8DHsdbgDDcuKsSBt3JWOLKLGV4qBbDB43Kki7adLuXgfkNHV9gLCr1iB4BRtTwEyKynSE0RzQ3s35WLGBvnBaBjyYapz557a1MCOHUmyCYLGD1dBpADZckjEm83UZiGeWnvJZ4LFJvjh4D3MIUo6KETiRNJunrai7YLCz35g0gTwoylAWad+JWYfAq4NZcLBd4nB4J9jShLvlUXxQHARomefucLFF4QB4MOzYBfitFH8zyWcHoYidOLCyunA0kJsYb5+X82pWrMOxfPU8MLCrgThwhJtS4f/4l/gGyAeN08Xlo');
//        var buffer = AMR.toWAV(result);
////        E('pre').textContent = toHex(buffer);
//        var url = URL.createObjectURL(new Blob([buffer], {type: 'audio/wav'}));
//        // Play wav buffer
//        var audio = new Audio(url);
//        audio.onloadedmetadata = audio.onerror = function () {
//            URL.revokeObjectURL(url);
//        };
//        audio.play();

//        playAmrBlob(E('#base64-input').value);
    };

    E('#base64-audio2 > button').onclick = function () {
        playAmrToWav('IyFBTVIKLEWGYIDYAbvFOH2GfsiOIegRLMIqLEkrjgtAHkTQivDmfVM1jaNZEngILE2GwAPEmHx5NDk7pUNLUfWYUsHoLEgkjgtMXPP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GWUxK3LevJNWNsLDj1Qg8DHsdbgDDcuKsSBt3JWOLKLGV4qBbDB43Kki7adLuXgfkNHV9gLCr1iB4BRtTwEyKynSE0RzQ3s35WLGBvnBaBjyYapz557a1MCOHUmyCYLGD1dBpADZckjEm83UZiGeWnvJZ4LFJvjh4D3MIUo6KETiRNJunrai7YLCz35g0gTwoylAWad+JWYfAq4NZcLBd4nB4J9jShLvlUXxQHARomefucLFF4QB4MOzYBfitFH8zyWcHoYidOLCyunA0kJsYb5+X82pWrMOxfPU8MLCrgThwhJtS4f/4l/gGyAeN08Xlo');
    };
    E('#base64-audio3 > button').onclick = function () {
        playAmrToWav('IyFBTVIKLEWGYIDYAbvFOH2GfsiOIegRLMIqLEkrjgtAHkTQivDmfVM1jaNZEngILE2GwAPEmHx5NDk7pUNLUfWYUsHoLEgkjgtMXPPQwhrzXi7BBeVsCTl8LCwkwAeF+DQZtU6aHy/oi85xm48+LEQZTg8IfgSxFs8MTWkmTJnCiVeQLAmWQA8DcwJqRyWK6D1JXNiGT1/kLCCtjhwg/i4HQxYBTh/FyL0c4PKGLEOUnB8ECWzBtivj/o0uCKBOSVwaLERviBwjOO1SQyDHHShqp6v5ntQ6LIK0jpaN20m16Ebxbex+FST/0L6cLESbnFiime8ELtBDikj7R/v6kpIGLJAYHB7i/IW3MtgZjH8HkdlbX+rQLENADj2QDXL1/KDsHpJRFQkItcEKLJA/slqjGeHpl6LdmIvkg+s3mzP6LGgYHB9gmUS7M7dqXkMDBu1gS3xCLE8Rhw5pGcJiYMXkGiFCKV12SAZSLEwYsh+gnLQ+jtRY/HnRKOJ9ze1kLGiksh/A3DJFpp97NdhcYOKEjY5wLEzDnJdhDXHBDiasPfK6kXn+4t5mLE7bjh9gmT5rYfVsrppPiaj1HjgMLE1TnB9APIbLx4jNHneWgW2iXYYqLE5vjhfiHD5ogLu4T3Qa1UbBahXaLEBHsh6D2gTTLIciRh0Tpc+iVlQILEXtmh8COJcs4kOVfNmoU5JsVakWLEPtnBygeM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wpm0brz3YZ5x2WjOtfJk1ILExHsh4JWJcFQhJ3G41WLeLxbOKELE8qvA8BFAh7Ayu/n3/QC3K6RziALGKjUBaQuYJNIf5SNlefkelZXdHKLEy0vBtJmTNtYwes7vyXUdPSa1IILClTUBwgSGp6STlsv9t2gH+kDWbALB4PvB0gABKm+hImnwV8APqdZESqLB4IvBwiYBAhMgCdOI3iAuM0M/bcLCnCvB4QkfzIOj5Yftvqne8ThXnaLBsyTh4AUxcAN1m1NHPfErnshny2LDCBjgtRngH0Uyp4vUqxCedYHn90LCgMtBhiCgXGoodefNWyYaHqE1/GLFHvwBxs1jRSisWI+Vp6yeSdnGcuLGLBNB6SAOpfVpFSl0N7MXVJmqayLGPvjB6wCd4Q9vtkrtWPMiiRFjsCLGPvOB4Qg3veV9o4e2WWCbLSuk8ELGOECB6KEKtFRBGWUxK3LevJNWNsLDj1Qg8DHsdbgDDcuKsSBt3JWOLKLGV4qBbDB43Kki7adLuXgfkNHV9gLCr1iB4BRtTwEyKynSE0RzQ3s35WLGBvnBaBjyYapz557a1MCOHUmyCYLGD1dBpADZckjEm83UZiGeWnvJZ4LFJvjh4D3MIUo6KETiRNJunrai7YLCz35g0gTwoylAWad+JWYfAq4NZcLBd4nB4J9jShLvlUXxQHARomefucLFF4QB4MOzYBfitFH8zyWcHoYidOLCyunA0kJsYb5+X82pWrMOxfPU8MLCrgThwhJtS4f/4l/gGyAeN08Xlo');
    };
    E('#base64-audio4 > button').onclick = function () {
        playAmrToWav('IyFBTVIKLEWGYIDYAbvFOH2GfsiOIegRLMIqLEkrjgtAHkTQivDmfVM1jaNZEngILE2GwAPEmHx5NDk7pUNLUfWYUsHoLEgkjgtMXPPQwhrzXi7BBeVsCTl8LCwkwAeF+DQZtU6aHy/oi85xm48+LEQZTg8IfgSxFs8MTWkmTJnCiVeQLAmWQA8DcwJqRyWK6D1JXNiGT1/kLCCtjhwg/i4HQxYBTh/FyL0c4PKGLEOUnB8ECWzBtivj/o0uCKBOSVwaLERviB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o6KETiRNJunrai7YLCz35g0gTwoylAWad+JWYfAq4NZcLBd4nB4J9jShLvlUXxQHARomefucLFF4QB4MOzYBfitFH8zyWcHoYidOLCyunA0kJsYb5+X82pWrMOxfPU8MLCrgThwhJtS4f/4l/gGyAeN08Xlo');
    };

    E('#base64-audio5 > button').onclick = function () {
        playAmrToWav('IyFBTVIKLEWGYIDYAbvFOH2GfsiOIegRLMIqLEkrjgtAHkTQivDmfVM1jaNZEngILE2GwAPEmHx5NDk7pUNLUfWYUsHoLEgkjgtMXPPQwhrzXi7BBeVsCTl8LCwkwAeF+DQZtU6aHy/oi85xm48+LEQZTg8IfgSxFs8MTWkmTJnCiVeQLAmWQA8DcwJqRyWK6D1JXNiGT1/kLCCtjhwg/i4HQxYBTh/FyL0c4PKGLEOUnB8ECWzBtivj/o0uCKBOSVwaLERviBwjOO1SQyDHHShqp6v5ntQ6LIK0jpaN20m16Ebxbex+FST/0L6cLESbnFiime8ELtBDikj7R/v6kpIGLJAYHB7i/IW3MtgZjH8HkdlbX+rQLENADj2QDXL1/KDsHpJRFQkItcEKLJA/slqjGeHpl6LdmIvkg+s3mzP6LGgYHB9gmUS7M7dqXkMDBu1gS3xCLE8Rhw5pGcJiYMXkGiFCKV12SAZSLEwYsh+gnLQ+jtRY/HnRKOJ9ze1kLGiksh/A3DJFpp97NdhcYOKEjY5wLEzDnJdhDXHBDiasPfK6kXn+4t5mLE7bjh9gmT5rYfVsrppPiaj1HjgMLE1TnB9APIbLx4jNHneWgW2iXYYqLE5vjhfiHD5ogLu4T3Qa1UbBahXaLEBHsh6D2gTTLIciRh0Tpc+iVlQILEXtmh8COJcs4kOVfNmoU5JsVakWLEPtnBygeMf3F/mGHbA4xUxe72hsLCGWTh9CmefiloFgDeKuKaG3U4vkLEQknB4Jmfbed4B0/leEBU/3kXvOLEJyKBaNmWa/9pZULJ81ybNlqQb6LEgkjh8gaDKMxnuUHlamQX/UemkgLGWM6DzrvLaw9ebQvsl/gdtq1JVWLCVtgjxU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0gABKm+hImnwV8APqdZESqLB4IvBwiYBAhMgCdOI3iAuM0M/bcLCnCvB4QkfzIOj5Yftvqne8ThXnaLBsyTh4AUxcAN1m1NHPfErnshny2LDCBjgtRngH0Uyp4vUqxCedYHn90LCgMtBhiCgXGoodefNWyYaHqE1/GLFHvwBxs1jRSisWI+Vp6yeSdnGcuLGLBNB6SAOpfVpFSl0N7MXVJmqayLGPvjB6wCd4Q9vtkrtWPMiiRFjsCLGPvOB4Qg3veV9o4e2WWCbLSuk8ELGOECB6KEKtFRBGWUxK3LevJNWNsLDj1Qg8DHsdbgDDcuKsSBt3JWOLKLGV4qBbDB43Kki7adLuXgfkNHV9gLCr1iB4BRtTwEyKynSE0RzQ3s35WLGBvnBaBjyYapz557a1MCOHUmyCYLGD1dBpADZckjEm83UZiGeWnvJZ4LFJvjh4D3MIUo6KETiRNJunrai7YLCz35g0gTwoylAWad+JWYfAq4NZcLBd4nB4J9jShLvlUXxQHARomefucLFF4QB4MOzYBfitFH8zyWcHoYidOLCyunA0kJsYb5+X82pWrMOxfPU8MLCrgThwhJtS4f/4l/gGyAeN08Xlo');
    };

    function playAmrToWav(amrStr) {
        if (null != src) {
            src.stop();
            src = null;
        }
        var amrStr = window.atob(amrStr),
            result = new Uint8Array(amrStr.length);
        for (var i = 0, l = amrStr.length; i < l; i++) {
            result[i] = amrStr.charCodeAt(i)
        }
        playAmrArray(result);
    }


    E('#audio-file').onchange = function () {
        convertAudioBlobToAmr(this.files[0]);
    };

    var gAudioContext = new AudioContext();

    function getAudioContext() {
        if (!gAudioContext) {
            gAudioContext = new AudioContext();
        }
        return gAudioContext;
    }

    function fetchBlob(url, callback) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.responseType = 'blob';
        xhr.onload = function () {
            callback(this.response);
        };
        xhr.onerror = function () {
            alert('Failed to fetch ' + url);
        };
        xhr.send();
    }

    function readBlob(blob, callback) {
        var reader = new FileReader();
        reader.onload = function (e) {
            var data = new Uint8Array(e.target.result);
            callback(data);
        };
        reader.readAsArrayBuffer(blob);
    }

    function fetchAndReadBlob(url, callback) {
        fetchBlob(url, function (blob) {
            readBlob(blob, callback);
        });
    }

    function playAmrBlob(blob, callback) {
        readBlob(blob, function (data) {
            playAmrArray(data);
        });
    }

    function convertAudioBlobToAmr(blob) {
        readBlob(blob, function (data) {
            var ctx = getAudioContext();
            ctx.decodeAudioData(data.buffer, function (audioBuffer) {
                var pcm;
                if (audioBuffer.copyFromChannel) {
                    pcm = new Float32Array(audioBuffer.length);
                    audioBuffer.copyFromChannel(pcm, 0, 0);
                } else {
                    pcm = audioBuffer.getChannelData(0);
                }
                var amr = AMR.encode(pcm, audioBuffer.sampleRate, 7);
                playAmrArray(amr);
            });
        });
    }

    function playAmrArray(array) {
        var samples = AMR.decode(array);
        if (!samples) {
            alert('Failed to decode!');
            return;
        }
        playPcm(samples);
    }
    var src = null;
    function playPcm(samples) {
        var ctx = getAudioContext();
        src = ctx.createBufferSource();
        var buffer = ctx.createBuffer(1, samples.length, 8000);
        if (buffer.copyToChannel) {
            buffer.copyToChannel(samples, 0, 0)
        } else {
            var channelBuffer = buffer.getChannelData(0);
            channelBuffer.set(samples);
        }

        src.buffer = buffer;
        src.connect(ctx.destination);
        src.start();
    }

    function convertAmrBlobToWav(blob) {
        readBlob(blob, function (data) {
            var buffer = AMR.toWAV(data);
            E('pre').textContent = toHex(buffer);
            var url = URL.createObjectURL(new Blob([buffer], {type: 'audio/x-wav'}));
            // Play wav buffer
            var audio = new Audio(url);
            audio.onloadedmetadata = audio.onerror = function () {
                URL.revokeObjectURL(url);
            };
            audio.play();
        });
    }

    function toHex(buffer) {
        var str = '';
        for (var i = 0; i < buffer.length; i++) {
            var s = buffer[i].toString(16);
            if (s.length == 1) {
                s = '0' + s;
            }
            str += s;
            if (i % 16 == 15) { // print 16 bytes per line
                str += '\n'
            } else if (i % 2 == 1) { // add a space seperator every two bytes.
                str += ' ';
            }
        }
        return str;
    }
</script>
</body>
</html>