I'm currently working on a web project using NodeJS that have video upload and player. The video uploaded will be stored in mongodb in binary form, and when retrive it via API localhost/api/media/:id :
/*getting media from db in binary format*/
res.setHeader('Accept-Ranges', 'bytes');
res.setHeader('Content-Range', 'bytes=0-1/' + media.length);
res.setHeader('Content-Type', 'video/mp4');
res.setHeader('Cache-Control', 'public,max-age=0');
res.send(media);
This work fine on Chrome and Firefox, using this API will give me a html5 page with video tag that look like this:
<video controls="" autoplay="" name="media">
<source src="localhost/api/media/abcde" type="video/mp4">
</video>
which run fine even on older Safari like 7. But on Safari 9 in particular it's not working and will only show the media controller with the text "loading" and can never play the video. I try to put the same video file in localhost and access it via localhost/test.mp4 and this run ok in Safari 9 so there's no problem with encoding of the video. Any idea how do I make this one work?