Audio data streaming in HTML5

后端 未结 2 2069
误落风尘
误落风尘 2020-12-04 17:20

I am receiving PCM audio data from the server in small chunks and having them stored in an Array. Now I would like to play these audio chunks sequentially without gaps using

2条回答
  •  天涯浪人
    2020-12-04 17:38

    Option 1 will probably not work because the audio tag doesn't play raw audio data (which I assume is what you mean by PCM audio data, or am I wrong?). Every browser needs specific codecs. To top it of the audio tag is not reliable at all to play things without gaps.

    Option 2 might work. The web audio api contains buffers which probably could be filled with raw data and played, but I've never tried doing so. The big drawback right now is that; a. Chrome only b. the user needs to configure chrome by typing about:flags and enable Web Audio which might be scary to some.

    A third option would be the Audio Data API which is something of a middle ground. I've never tried it myself, but from the spec it looks like exactly what you're looking for. I dunno about implementations though, so you'd have to do some research on your own :) https://wiki.mozilla.org/Audio_Data_API#Writing_Audio

    Please not that I'm giving these answers on top of my head, and I'm still pretty new to HTML5 audio.

提交回复
热议问题