Home > Article > Web Front-end > Stream video files to HTML5 video player using Node.js so video controls continue to work
Use createReadStream to send the requested portion to the client. The function call createReadStream() will give you a readable stream.
The following is the code -
stream = fs.createReadStream(path); stream.on('open', function () { res.writeHead(206,{ "Content-Range":"bytes " + begin + "-" + end + "/" +total, "Accept-Ranges":"bytes", "Content-Length":chunksize, "Content-Type":"new/mp4" }); stream.pipe(res); });
The above is the detailed content of Stream video files to HTML5 video player using Node.js so video controls continue to work. For more information, please follow other related articles on the PHP Chinese website!