HTML5 视频无法在 Safari 中播放

发布于 2024-12-22 11:22:03 字数 1103 浏览 3 评论 0原文

我一直致力于 HTML5 视频实现,但遇到了一些问题。我一直在遵循 http://diveintohtml5.info/video.html 上的指南。我已对所有视频进行了 .m4v、.ogv 和 .webm 版本的编码。 Chrome 和 Firefox 播放视频没有任何问题。当我尝试在 Safari 中播放它时,它会加载视频容器,但不会加载视频。您会看到视频所在的空白区域、控件和“正在加载”文本。在 Web Inspector 的网络选项卡中,视频的状态为“待处理”,mime 类型为“未定义”。有趣的是,我只在临时站点上遇到这个问题,而它在我的本地开发人员上运行良好。

当我直接在本地开发的浏览器中访问视频时,我在控制台中得到以下输出:

Resource interpreted as Document but transferred with MIME type video/x-m4v.
GET http://site.dev/content/videos/movie.m4v Plug-in handled load

请注意,检查器中 GET 的左侧有一个小红色 x。

我的 html 代码如下所示:

<video class="html5-video" width="700" controls>
    <source src="content/videos/movie.m4v" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
    <source src="content/videos/movie.webm" type='video/webm; codecs="vp8, vorbis"' />
    <source src="content/videos/movie.ogv" type='video/ogg; codecs="theora, vorbis"' />
    Your browser does not support this video.
</video>

另外,视频约为 20mb。

有什么想法吗?谢谢!

I've been working on an HTML5 video implementation, but I'm having some issues. I've been following the guide at http://diveintohtml5.info/video.html. I have encoded .m4v, .ogv, and .webm versions of all of the video. Chrome and Firefox have no troubles playing the video. When I attempt to play it in Safari, it loads the video container, but not the video. You see a white space where the video should be, the controls, and the "loading" text. In Web Inspector's network tab, the video's status is "pending" and the mime-type is "undefined". Interestingly, I only experience this problem on the staging site, while it works fine on my local dev.

When I visit the video directly in the browser on local dev, I get the following output in the console:

Resource interpreted as Document but transferred with MIME type video/x-m4v.
GET http://site.dev/content/videos/movie.m4v Plug-in handled load

Note that GET has a little red x to the left of it in the inspector.

My html code looks like:

<video class="html5-video" width="700" controls>
    <source src="content/videos/movie.m4v" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
    <source src="content/videos/movie.webm" type='video/webm; codecs="vp8, vorbis"' />
    <source src="content/videos/movie.ogv" type='video/ogg; codecs="theora, vorbis"' />
    Your browser does not support this video.
</video>

Additionally, the video is ~20mb.

Any thoughts? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事与诗 2024-12-29 11:22:03

嗯...事实证明,问题的发生是因为我使用 .htaccess 来密码保护目录。有趣的是,除 Safari 之外的所有浏览器都允许访问视频文件。感谢那些提供帮助的人!

Well...it turns out that the issue occurred because I was using .htaccess to password protect the directory. Interestingly, all browsers except for Safari would allow access to the video files. Thanks to those who helped!

秋日私语 2024-12-29 11:22:03

尝试编码为 mp4 并替换此文件而不是 m4v 格式,更新代码并运行。
工作还好啊

Try encoding to mp4 and replace this file instead m4v format, update your code and run.
Work's fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文