在 IE(7+) 中嵌入音频,并具有 JavaScript 静音和取消静音功能
我一直在寻找一种将音频嵌入网站的方法,具有循环和自动播放的能力,并且还能够使用 JavaScript 将音频静音和取消静音。我知道这在 html5 中是可能的并且非常容易,但我听说 IE 还不支持 html5(或者可能不支持音频标签)。
我还需要我的嵌入式音频能够在 IE7 之前工作。所以我认为使用标签适用于除 IE 之外的所有其他浏览器,而我希望类似的东西也适用于 IE;不幸的是,它不支持从 javascript 调用静音和取消静音 - 这是因为我不希望音频播放器中的任何控件可见;只是一个自定义声音按钮,用户可以单击该按钮来静音和取消静音。有什么想法吗?似乎这样的事情是最简单的事情,但却是最难编码的事情:/
I've been looking around for a method to embed audio onto a website, have a capability to loop and autoplay and also be able to mute and unmute the audio with javascript. I know that this is possible and very easy in html5, but I've heard that IE doesn't support html5 yet (or the audio tags perhaps).
I also need my embedded audio to work as far back as IE7. So i think that using the tags will work for all other browsers but IE, while I was hoping something like could work for IE; unfortunately, it doesn't support calls from javascript to mute and unmute - this is because I don't want any controls from the audio player to be visible; simply a custom sound button that the user can click to mute and unmute the audio. Any ideas? Seems that something like this is the most simple thing, but the hardest thing to code :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑使用默认使用 HTML 5 的播放器,但如果不支持 Flash,则可以使用 Flash。
JPlayer 可以做到这一点,并且有一个 静音功能。
Consider using a player that uses HTML 5 by default, but can fall back on Flash if it's not supported.
JPlayer can do that, and has a mute function.
HTML5 是您最好的选择。
您可能需要在音频标记中指定的属性是
controls='controls'
以启用播放选项,例如播放暂停和音量控制(包括静音);loop='loop'
启用自动循环;autoplay='autoplay'
显然是自动播放;和preload='auto'
在页面加载时加载音频(您也可以指定“元数据”或“无”),您的播放器可能如下所示:
HTML5 is your best bet.
the attributes you might want to specify in the audio tag are
controls='controls'
to enable playback options like play pause and volume controls including mute;loop='loop'
to enable auto-loop;autoplay='autoplay'
obviously to autoplay; andpreload='auto'
to load the audio on page load (you can also specify "metadata" or "none")your player would probably look like: