- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Streaming a video file to an HTML5 video player with Node.js so that the video controls continue to work
Use createReadStream to send the requested part to the client. The function call createReadStream() will give you a readable stream.
Example
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); });
- Related Articles
- Play local (hard-drive) video file with HTML5 video tag?
- How to take a snapshot of HTML5-JavaScript based video player?
- HTML DOM Video controls Property
- Commonly used Video formats while using HTML5 video
- How to include the audio/video controls in HTML?
- Creating a responsive Video Player using Video.js
- Display video inside HTML5 canvas
- Using FFMPEG with HTML5 for online video hosting
- Use CSS width property for a responsive video player
- Converting video to HTML5 ogg / ogv and mpg4
- HTML5 video not playing in Firefox
- HTML5 video full preload in JavaScript
- How to add video chapters in YouTube video description
- Setting up a Poster for a Video in Video.js Player
- How to prevent the HTML5 video from loading before playing?

Advertisements