<video> plays in other browsers, but not Safari

后端 未结 11 1526
清酒与你
清酒与你 2020-12-06 04:30

We have an MP4 video on our site; it plays fine in IE9+, Firefox, Chrome, and Chrome on mac. However, on Safari, the video doesn\'t play at all - it does trigger a \"stalled

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 04:56

    Please, forgive me if you already solve this issue! I've had the same problem with my server videos in Safari. I was abled to solve this using POSTMAN/INSOMNIA for check the headers that my server is sending. Chrome may can trick your, once that in this browser the video works fine!

    If the video is not ranged(full video request) your server must return status(200) and check it out if the 'Accept-Ranges:bytes' is sent from your server. Header sample status 200:

    Server: nginx
    Date: Wed, 25 Jul 2018 17:34:18 GMT
    Content-Type: video/mp4
    Content-Length: 22995782
    Connection: keep-alive
    X-Powered-By: Express
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE
    Access-Control-Allow-Headers: X-Requested-With,content-type
    Access-Control-Allow-Credentials: true
    Accept-Ranges: bytes
    

    if the video is ranged your server must return status(206) with range headers correctly. Header sample status 206:

    Server: nginx
    Date: Wed, 25 Jul 2018 18:13:07 GMT
    Content-Type: video/mp4
    Content-Length: 1023
    Connection: keep-alive
    X-Powered-By: Express
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE
    Access-Control-Allow-Headers: X-Requested-With,content-type
    Access-Control-Allow-Credentials: true
    Accept-Ranges: bytes
    Content-Range: bytes 1-1023/22995782
    

    I hope this help you! my best regards, Paulo Durço

提交回复
热议问题