向后跨浏览器兼容的音频播放 [英] Backwards and cross-browser compatible audio playing

查看:164
本文介绍了向后跨浏览器兼容的音频播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要回放在许多不同的Web浏览器和不同版本的音频文件。旧的系统产生4位的WAV文件,其中有许多浏览器无法处理。每个文件都含有合成的或录制的人声。反正我会需要更换。所以我的问题是:

I need to playback audio files in many different web browsers and different versions. The old system produces 4-bit WAV files, which many browsers can't handle. All files contain synthesized or recorded human voices. Anyway I'm gonna need to replace it. So my questions are:

1)什么是用于音频文件,关于兼容性,大小和质量

1) what is the best file format to use for audio files, with regards to compatibility, size and quality?

2)什么是使用HTML5和最佳的方式停留向后兼容?

2) what is the best way to use HTML5 and staying backwards-compatible?

我们需要支持的Internet Explorer版本6,7,8和9;火狐,Chrome和Safari。

We need to support Internet Explorer versions 6, 7, 8 and 9; Firefox, Chrome and Safari.

更新:终于得到它的IE浏览器6-9的工作,Firefox和Chrome;没有测试Safari浏览器呢。我了解到,Windows版Safari需要QuickTime和IE浏览器需要Windows媒体播放器。

Update: finally got it working for IE 6-9, Firefox and Chrome; haven't tested Safari yet. I learned that Safari for windows requires Quicktime and IE requires windows media player.

推荐答案

下面就是我使用的是什么:

Here's what I'm using:

<audio autoplay>
    <source src="/static/sound/SOUND.mp3" type="audio/mpeg">
    <source src="/static/sound/SOUND.ogg" type="audio/ogg">
    <source src="/static/sound/SOUND.wav" type="audio/wav">
    <source src="/static/sound/SOUND.aiff" type="audio/x-aiff">
    <object>
        <param name="autostart" value="true">
        <param name="src" value="/static/sound/SOUND.mp3">
        <param name="autoplay" value="true">
        <param name="controller" value="false">
        <embed src="/static/sound/SOUND.mp3" controller="false" autoplay="true" autostart="true" type="audio/mpeg"></embed>
    </object>
</audio>

我公司提供的相同的音频剪辑MP3,OGG,WAV和AIFF然后让浏览器选择哪个就是了玩。在音频标签是HTML5中,对象标记是较老的系统,而嵌入工作在某些系统上不支持的对象标记。

I provide the same audio clip in MP3, OGG, WAV, and AIFF and then let the browser pick which it wants to play. The audio tag is for HTML5, the object tag is for older systems, and embed works on some systems not supporting the object tag.

我把这个一起从几个网站的一些信息,但不幸的是我忘了网址。

I put this together from some information on a few websites, but unfortunately I've forgotten the URL.

我自切换到使用 howler.js 这个东西。它与所有相关的声音跨浏览器的问题,自动造成。遗憾的是它不支持IE 6-8,但我已经放弃了那些支持任何方式。

I've since switched to using howler.js for this stuff. It automatically deals with all the cross-browser issues related to sound. Unfortunately it doesn't support IE 6-8, but I've given up supporting those any way.

这篇关于向后跨浏览器兼容的音频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆