MediaElement.js 带音频标签的 Flash 回退
我想实现一个带有 Flash 后备功能的音频标签。该网站上没有示例,我不确定如何去做。我有一个 MP3,我想播放,它在 Webkit 浏览器上工作正常,正如预期的那样,但它不能在 Firefox 和 IE 上工作。
我尝试通过使用示例中的 Flash 回退来模拟视频元素来实现类似的操作。
<audio id="audio-bloop" controls="controls">
<source src="audio/digital-boop.mp3" type="audio/mp3" />
<!-- Flash Fallback -->
<object width="640" height="360" type="application/x-shockwave-flash" data="flashmediaelement.swf">
<param name="audio" value="videos/build/flashmediaelement.swf" />
<param id="flashvars-param" name="flashvars" value="controls=falseg&file=audio/digital-boop.mp3" />
</object>
</audio>
然而,这是行不通的。如何使用 MediaElement.js 为音频标签提供 Flash 后备支持?
编辑:
在查看 MediaElement.js 主页上的源代码后,我尝试了此操作:
<audio id="audio-bloop" controls="false" preload="auto" src="audio/digital-boop.mp3" type="audio/mp3"></audio>
加上此:
audioPlayer = new MediaElementPlayer("#audio-bloop", {
pluginPath: '../videos/build/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap'
});
但仍然没有成功。同样,该视频在 IE9、Safari 和 Google Chrome 中运行良好,但在 IE6-7 或 Firefox 和 Opera 中则无法运行。
编辑:我无法让 Flash 回退工作,所以目前我使用另一个源标签来添加文件的 .wav 格式。
I would like to implement an audio tag with Flash fallback. There are no examples on the site and I am unsure how to go about doing this. I have an MP3 that I would like to play and it works fine on Webkit browsers as expected however it does not work with Firefox and assumingly IE.
I have tried implementing something like this by mocking the video element with Flash fallback from examples.
<audio id="audio-bloop" controls="controls">
<source src="audio/digital-boop.mp3" type="audio/mp3" />
<!-- Flash Fallback -->
<object width="640" height="360" type="application/x-shockwave-flash" data="flashmediaelement.swf">
<param name="audio" value="videos/build/flashmediaelement.swf" />
<param id="flashvars-param" name="flashvars" value="controls=falseg&file=audio/digital-boop.mp3" />
</object>
</audio>
This, however, does not work. How can I go about providing Flash fallback support for audio tags using MediaElement.js?
EDIT:
I attempted this after viewing the source on the MediaElement.js home page:
<audio id="audio-bloop" controls="false" preload="auto" src="audio/digital-boop.mp3" type="audio/mp3"></audio>
Coupled with this:
audioPlayer = new MediaElementPlayer("#audio-bloop", {
pluginPath: '../videos/build/',
// name of flash file
flashName: 'flashmediaelement.swf',
// name of silverlight file
silverlightName: 'silverlightmediaelement.xap'
});
And still had no success. Again, the video works fine in IE9, Safari, and Google Chrome, but no goin IE6-7 or Firefox and Opera.
EDIT: I was not able to get the Flash fallback working, so for the time being I am using another source tag to add a .wav format of the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我使用 Media Element JS(版本 2.9.3)时,这就是我对 Audio 元素所做的,它适用于 IE 8+、Firefox、Safari、Chrome 的最新版本(截至撰写本文时)。
JS
HTML
CSS
如果 HTML 5 不是支持Flash后备自动加载。
When I used Media Element JS (version 2.9.3) this is what I did for Audio element and it works in IE 8+, latest versions (as of this writing) of Firefox, Safari, Chrome.
JS
HTML
CSS
If HTML 5 is not supported the Flash fallback is automatically loaded.