在Node.js中stream式传输video的一部分

我正在使用模块( BinaryJS )将存储在服务器中的video传递给浏览器(客户端)。

我的目标是不播放整个video,而是一部分。

我试过的是

//Creating the client var client = new BinaryClient('ws://localhost:9000/binary-endpoint') //Inserting the video element in the body var video = document.createElement("video"); document.body.appendChild(video); //Array where the arrayBuffers will be stored var parts = []; client.on('stream', function(stream,meta){ stream.on('data',function(data){ parts.push(data); }); stream.on('end',function(){ video.src = (window.URL||window.webkitURL).createObjectURL(new Blob(parts.slice(0,500))); $('video')[0].play(); $('video')[0].controls=true; }) }); 

请注意,为了实现目标,我只给部分接收到的数据( parts.slice(0,500) )提供了Blob构造函数。

上面的代码不起作用,除非我给Blob提供整个接收的数据 – new Blob(parts)

这个问题有什么更好的解决方法?

我感谢任何帮助。