Latest Safari v11.0 fails to play videos with MP4s which have been set dynamically via JavaScript. But that works fine on Chrome, Edge and FF.
My code sets the src
element pointing to a MP4 resource like that:
<video class="replay" autoplay="true" autostart="true" autobuffer="true" playsinline="true" webkit-playsinline="webkit-playsinline" controls="controls" style="" preload="auto" muted="true">
<source src="https://videomail.io/videomail/11e7-ad5a-4b14b680-a354-934ec5b49c33/preview/type/mp4/x-videomail-site-name/videomail.io/videomail.mp4?1507598907103" type="video/mp4">
</video>
The problem is that Safari highlights this in red under the Network tab:
Under Request & Response (on right) it says it got cancelled. Why?
Plus under Request Headers I see: Range bytes=0-1
. Seems weird. Although I curled that resource and looks fine, can be downloaded completely.
Tried many different changes, all fail. Not sure if it's an Nginx issue, a bug in my JS code, or a Safari thing.
It is very easy to reproduce:
---- FINAL SOLUTION ----
Fixed this myself by using following in the express.js controller code:
res.sendFile(file, {
lastModified: false,
acceptRanges: true,
cacheControl: false
}, function (err) {
if (err && err.code !== 'ECONNRESET') {
next(err)
}
})