Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for ms-stream #1

Open
jonnyreeves opened this issue Sep 21, 2016 · 4 comments
Open

Add Support for ms-stream #1

jonnyreeves opened this issue Sep 21, 2016 · 4 comments

Comments

@jonnyreeves
Copy link
Owner

See jonnyreeves/chunked-request#10 for context and research.

@jimmywarting
Copy link

jimmywarting commented Sep 24, 2016

Sitting on a mac and don't have windows... But I think it's something like this:

var xhr = new XMLHttpRequest

function readyStateCallback() {
    if (xhr.readyState == 3) {
        var msstream = xhr.response // MSStream object

        var reader = new MSStreamReader()
        reader.onprogress = function () {
            console.log(reader.result) // need to slice it (it expands)
            // enqueue chunk (Uint8Array) to ReadableStream
        }
        reader.onload = function () {
            console.log(reader.result)
            // Done, close stream?
        }

        reader.readAsArrayBuffer(msstream)
    }
}

xhr.open('GET', 'http://myserver/myfile')
xhr.responseType = 'ms-stream'
xhr.onreadystatechange = readyStateCallback
xhr.send(null)

@jimmywarting
Copy link

I decided to investigate this further today and manage to get a ms-stream and convert it to a ReadableStream. and then i found this:

/* Notice: ms-stream may cause IE/Edge browser crash if seek too frequently!!!
 * The browser may crash in wininet.dll. Disable for now.
 *
 * For IE11/Edge browser by microsoft which supports `xhr.responseType = 'ms-stream'`
 * Notice that ms-stream API sucks. The buffer is always expanding along with downloading.
 *
 * We need to abort the xhr if buffer size exceeded limit size (e.g. 16 MiB), then do reconnect.
 * in order to release previous ArrayBuffer to avoid memory leak
 *
 * Otherwise, the ArrayBuffer will increase to a terrible size that equals final file size.
 */

src: https://github.com/6600/flvPlay/blob/aa8159a8fbc2cb85465503b97fb1c50880b6db10/src/io/xhr-msstream-loader.js

So i guess the best thing to do is partial download... :(

@Mouvedia
Copy link

Mouvedia commented Jul 26, 2018

@jimmywarting once detached you gotta use AsStreamForRead.

@Yaffle
Copy link

Yaffle commented Feb 9, 2020

It seems, MSStreamReader also does not fire progress events for every small chunk of data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants