Answer the question
In order to leave comments, you need to log in
Why is video stream not working in safari?
Hello, I'm transferring the video to the user via stream, everything works in chrome, but it doesn't work in safari.
fs.stat(pathFile, (err, stats) => {
if (err) {
// файл не найден
} else {
const { range } = req.headers;
const { size } = stats;
const start = Number((range || '').replace(/bytes=/, '').split('-')[0]);
const end = size - 1;
const chunkSize = (end - start) + 1;
res.set({
'Content-Range': `bytes ${start}-${end}/${size}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunkSize,
'Content-Type': 'video/mp4'
});
res.status(206);
const stream = fs.createReadStream(pathFile, { start, end });
stream.on('open', () => stream.pipe(res));
stream.on('error', (streamErr) => res.end(streamErr));
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question