In case anyone requires any help or advice on this issue. I managed to write a custom controller to stream mp4 video file to all devices including iOS mobile devices. See the code snippet below for streaming mp4 video file from odoo. Hope the code works for you, but streaming mp4 file from odoo is not recommended because of odoo is not meant for streaming media and it will affect odoo's performance if the video request gets too much.
Thus, my recommended solution is to setup apache2 to serve the video media. The load speed of the video is drastically faster than loading from odoo.
Hope this helps.
@http.route(['/mainvideo'], type='http', auth="public", website=True)
def website_mainvideo(self, **post):
cr, uid, context, registry = request.cr, request.uid, request.context, request.registry
mainvideo = ""
with open("static/src/videos/homepage.mp4", 'rb') as mp4_file:
mainvideo = mp4_file.read()
headers = [('Content-Type', 'video/mp4'),('Accept-Ranges', 'bytes')]
status = 200
if request.httprequest.range:
contentrange = request.httprequest.range.make_content_range(len(mainvideo))
if contentrange.stop < len(mainvideo):
status = 206
headers.append(('Content-Range','bytes %s-%s/%s' % (str(contentrange.start), str(contentrange.stop), str(len(mainvideo)))))
elif contentrange.stop > len(mainvideo):
status = 416
mainvideo = ""
if status != 416:
mainvideo = mainvideo[contentrange.start:contentrange.stop]
headers.append(('Content-Length', len(mainvideo)))
response = Response(mainvideo, status=status, headers=headers, content_type="video/mp4")
return response