HTML5 和音频标签:不包含文件扩展名的重定向链接无法在 FF/Chromium 中加载

发布于 2024-11-18 20:59:30 字数 2058 浏览 6 评论 0原文

我有一个关于

我们有要使用相应的 HTML5

以下代码是网页中应显示 HTML5 播放器的部分:

    <div class="mainContent">
    <audio id="aud1" height="360" width="640" autoplay="false" controls="controls" tabindex="0">
    <source type="audio/ogg" src="http://localhost:1234/a/b/cdefg/Xyz"></source>
    Your browser does not support HTML5.
    </audio>
    <div class="divider"></div>
    <a class="homeLink" href="/index.html">Take me back to the Homepage</a>
    </div>

正在播放的媒体肯定是纯音频 OGG 文件。

我已经在 Ubuntu 10.04 FF5.0、Chromium 12.0.742.91 (87961) 和 Opera 11.50 上测试了此代码,结果如下:

  1. FF: 不播放
  2. Chromium: 不播放
  3. Opera: 好的

我集成了一个小的脚本来显示 HTMLMediaElement 的不同属性(属性:networkState、readyState,请参阅),产生以下结果:

  1. FF => networkState: NETWORK_LOADED(媒体源加载完毕),readyState: HAVE_NOTHING(没有可播放的媒体)
  2. Chromium => networkState: NETWORK_LOADED(媒体源加载完毕),readyState: HAVE_NOTHING(没有可播放的媒体)
  3. Opera => networkState:NETWORK_IDLE,readyState:HAVE_ENOUGH_DATA

(请注意,不同状态的描述来自 Safari 开发站点:http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/HTMLMediaElementClassReference/HTMLMediaElement/HTMLMediaElement.html

如果我插入src 直接指向纯音频 OGG 文件(例如 http://en.wikipedia.org/wiki/File:Tromboon-sample.ogg),然后它按预期工作。 FF 和 Chromium 似乎在不包含最终文件名的链接方面存在问题?

有人对此有想法或提示吗?

干杯, 克里斯

I have an annoying problem regarding the <audio> tag and FF/Chromium as media won't be played back when I would expect it to. Opera seems to handle it correctly.

We have audio media to be played back using the corresponding HTML5 <audio> tag. The <source> tag includes media in an audio-only OGG container.
However, the file-extension ogg is not in the src-attribute, so src-links look like http://localhost:1234/a/b/cdefg/Xyz (Restful API using redirection to get the actual media file).

The following code is the part of the web page that should display the HTML5 player:

    <div class="mainContent">
    <audio id="aud1" height="360" width="640" autoplay="false" controls="controls" tabindex="0">
    <source type="audio/ogg" src="http://localhost:1234/a/b/cdefg/Xyz"></source>
    Your browser does not support HTML5.
    </audio>
    <div class="divider"></div>
    <a class="homeLink" href="/index.html">Take me back to the Homepage</a>
    </div>

The media being played back is definitely a audio-only OGG file.

I have tested this code on Ubuntu 10.04 FF5.0, Chromium 12.0.742.91 (87961) and Opera 11.50 with the following results:

  1. FF: doesn't play back
  2. Chromium: doesn't play back
  3. Opera: OK

I've integrated a small script to display different attributes of the HTMLMediaElement (attributes: networkState, readyState, see) yielding the following results:

  1. FF => networkState: NETWORK_LOADED (media source finished loading), readyState: HAVE_NOTHING (no media available for playback)
  2. Chromium => networkState: NETWORK_LOADED (media source finished loading), readyState: HAVE_NOTHING (no media available for playback)
  3. Opera => networkState: NETWORK_IDLE, readyState: HAVE_ENOUGH_DATA

(Note that the descriptions for the different states are from the Safari Dev site: http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/HTMLMediaElementClassReference/HTMLMediaElement/HTMLMediaElement.html)

If I insert a src which directly points to an audio-only OGG file (like http://en.wikipedia.org/wiki/File:Tromboon-sample.ogg), then it works as expected.
It seems as if FF and Chromium seems to have issues with links not including the final file name?

Does anyone have an idea or hint about this?

Cheers,
Chris

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

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

发布评论

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

评论(1

深府石板幽径 2024-11-25 20:59:30

我知道您已经修复了它,但请确保您没有错过任何 MIME 类型:

HTML5

.ogv
video/ogg

.webm
video/webm

HTML5

.oga
audio/ogg

.mp3
audio/mp3

HTML5

.mp4
video/mp4

.ogg
application/ogg

I know you already fixed it, but make sure you didnt miss any MIME types:

HTML5 <video>

.ogv
video/ogg

.webm
video/webm

HTML5 <audio>

.oga
audio/ogg

.mp3
audio/mp3

HTML5 <video> <audio>

.mp4
video/mp4

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