javascript - Is it possible that stream mp3 as blob? - Stack Overflow

I wrote a simple code that PHP sends mp3 data as blob and in client side (JS) html5 audio object plays

I wrote a simple code that PHP sends mp3 data as blob and in client side (JS) html5 audio object plays it but the problem is : first whole of file should be fetched and then audio can be played.

function blob(uri){

    $.ajax({

        type: "POST",
        url:uri,


        success:function(result){

            let binary = convertDataURIToBinary(result);
            let blob = new Blob([binary], {type : 'audio/mp3'});
            let uri= URL.createObjectURL(blob);

            audio.src = uri;
            audio.load();

            audio.play().then(

            r => {
                
                //do something
            }

            ).catch((error) => {

                checkInternet();
            });
    

        }});

}

Blockquote

So my question : is it possible that I send data as blob and before sending whole file, audio plays? or I have to implement a client js player myself to do that?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742411422a4438889.html

相关推荐

  • javascript - Is it possible that stream mp3 as blob? - Stack Overflow

    I wrote a simple code that PHP sends mp3 data as blob and in client side (JS) html5 audio object plays

    14小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信