Safari上的HTML5视频问题 [英] HTML5 video problems on Safari
问题描述
我遇到的问题是,视频无法在Safari中运行,但可以与Chrome和Firefox完美配合.
I'm have the problem that video doesn't work in Safari, but works perfectly fine with Chrome and Firefox.
<video controls muted preload="none" playsinline src="/path/to/video" type="video/mp4"/>
获取fom VLC编解码器信息:
Get fom VLC codec informations:
视频h.264/mpeg-4 avc
video h.264/mpeg-4 avc
音频mpeg aac音频mp4a
audio mpeg aac audio mp4a
推荐答案
这确实是Safari中的错误*(至少12.0.2),该错误*不接受获取此
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.
您可以通过
- 设置服务器以使其接受Range请求(即使对于其他浏览器,这也是最好的解决方案).
- 发生错误时,请通过AJAX提取整个文件,然后从内存中播放(作为Blob).但这意味着要等待400MB下载.
- 发生错误时,获取文件并通过管道发送 ReadableStream 到 MediaSource 的
appendStream()
方法.但是还没有浏览器支持它...
*尽管我发现为iOS托管媒体文件的HTTP服务器必须支持字节范围请求",因此,对于iOS,但是它们对台式机的约束可能相同.但是它们不支持非范围请求,无论如何都听起来像是一个错误,因为它违反了规范.
*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.
这篇关于Safari上的HTML5视频问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!