HTML5 video problems on Safari

后端 未结 3 1939
无人及你
无人及你 2020-12-21 23:42

I\'m have the problem that video doesn\'t work in Safari, but works perfectly fine with Chrome and Firefox.

相关标签:
3条回答
  • 2020-12-22 00:00

    This is indeed a bug* in Safari (at least 12.0.2), which doesn't accept to fetch this 300MB video as a single Request from the MediaElement.
    They try desperately to make a Range request, but your host doesn't allow such requests. You can see it by trying to seek in the video while not fully loaded in other browsers.

    You could workaround that issue by either

    • Setting your server so that it accepts Range requests (that would be the best solution, even for other browsers).
    • On error, fetch the whole file through AJAX and play it from memory (as a Blob). But this means waiting for the 400MB to be downloaded.
    • On error, fetch the file and pipe a ReadableStream to a MediaSource's SourceBuffer using its appendStream() method. But no browsers supports it yet...

    *Though I found this link which says that "HTTP servers hosting media files for iOS must support byte-range requests", so it is for iOS, but they probably have the same constraints for desktop. But that they do not support non-range requests sounds like a bug anyway as it goes against the specs.

    0 讨论(0)
  • 2020-12-22 00:20

    If you haven’t solved the problem yet then go to your phone setting then choose safari and tap Clear History and Website Data, that worked for me the problem wasn’t the code but safari itself.

    0 讨论(0)
  • 2020-12-22 00:21

    Another possible solution for you future searchers: (If your problem is not a mimetype issue.)

    For some reason videos would not play on iPad unless i set the controls="true" flag.

    Example: This worked for me on iPhone but not iPad.

    <video loop autoplay width='100%' height='100%' src='//some_video.mp4' type='video/mp4'></video>
    
    0 讨论(0)
提交回复
热议问题