简体   繁体   中英

WebKit equivalent to Firefox's “moz-chunked-arraybuffer” xhr responseType

I would like to read an MP3 stream (from icecast, to read ICY metadata an then pass the binary MP3 data to a Web Audio Api).

Firefox has a "moz-chunked-arraybuffer" xhr responseType to read data on progress, but I can't find any equivalent for webkit / chrome.


EDIT 2014/02/03 :

Chrome has started implementing xhr.responseType "stream"

The "parsing" is landed in Chrome (with the --enable-experimental-webkit-features flag) but the xhr.response resulted object (Stream) is not yet useable directly in Javascript : https://code.google.com/p/chromium/issues/detail?id=240603


EDIT 2014/07/10 :

The spec is now developped : https://github.com/whatwg/streams

Chromium devs plans to "do some prototype without waiting for completion of standardization"


EDIT 2015/01/22 :

The Streams API will not be implemented in XHR (it was just for prototyping). It will finally be implemented in the Fetch API implementation, which was recently shipped in Chrome (behind the experimental flag).


EDIT 2015/01/30 : Fetch API has an Intent to Ship ! Streams API are announced as "upcoming integrations", it's quite here !


EDIT 2015/04/15 :

\\o/ Glory ! The Fetch API is now landed in Chrome 42 (current stable release : http://googlechromereleases.blogspot.fr/2015/04/stable-channel-update_14.html ). 42 is not only the answer to life, the universe and everything but also to this question "How can I consume an "AJAX request" like a stream" :

https://github.com/GoogleChrome/samples/blob/gh-pages/fetch-api/fetch-response-stream.html

End of the story :)

Sorry to be the bearer of bad news, but to my knowledge there's not currently a webkit equivalent. Originally the chunked-arraybuffer response type arose from a concern similar to yours:

http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/0924.html

Additionally, MDN lists the responseType as only available in Firefox:

https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest

I think the solution to your issue is not having seen the full AudioContext object for html5.

http://www.html5rocks.com/en/tutorials/webaudio/intro/

You can decode audio data : decodeAudioData() You can play music via an AudioBuffer that can stream music to you via a web socket or just chunked http streaming.

When you want to play a song you just call the playSound()

So the real answer is use the AudioContext and you'll be golden

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM