Rendering a video stream as partial content rather than a full stream in chrome

We are currently sending a video playback request to the back server, which sends the full stream as input for playback in a browser (window). This works great, but has the added complication that the search function doesn't work in chrome. The proposed solution is to tell the web server that it needs to accept a range of bytes, and then deliver the stream in partial byte ranges. I'm not sure if this solves the situation, but my question is how to return the stream to byte ranges, given that this is now done like this:

    InputStream is= null;
    is = new FileInputStream(ndirectoryFile);

    ....
    //(calling class request)
    stream = videoWrapper.getVideo(id, address);

If I read the file in byte ranges, I just look at the file, but how to send the answer:

InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); 
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[1024];
while ((nRead = is.read(data, 0, data.length)) != -1) {
    buffer.write(data, 0, nRead);
}

buffer.flush();
byte[] byteArray = buffer.toByteArray(

. , .

EDIT:

html5- . , Accept-Ranges =, Content-length =, Content-Range =, chrome , . firefox, ? ? ?

+4
1

, - , , , , .

Accept-Ranges: bytes
Content-Range: bytes 0-1025/905357
Content-Length: 905357
0

Source: https://habr.com/ru/post/1693410/


All Articles