HTML5音频无法在ie7或ie8中工作 [英] HTML5 Audio not working in ie7 or ie8

查看:95
本文介绍了HTML5音频无法在ie7或ie8中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE7 / 8中测试时,我的脚本崩溃,我收到此错误...

When testing in IE7/8 my script crashes and I get this error...


SCRIPT438:对象不支持属性或方法'play'

SCRIPT438: Object doesn't support property or method 'play'

我正在使用HTML5音频标签在我的网页上嵌入和播放音频。

I'm using the HTML5 audio tag to embed and play audio on my webpage.

<div id="auido-container">
        <audio id="music" loop="loop">
            <source src="audio/holiday-for-mr-anderson-60secs.mp3"></source>
            <source src="audio/holiday-for-mr-anderson-60secs.ogg"></source>
            Your browser isn't invited for super fun audio time.
        </audio>
        <audio id="sound">
            <source src="audio/pop.mp3"></source>
            <source src="audio/pop.ogg"></source>
            Your browser isn't invited for super fun audio time.
        </audio>

    </div>

我的JS看起来像这样:

My JS looks like this:

start.click(function(){
    audio.play();
});

我已将此包含在我的标题中:

I've included this in my header:

<!--[if IE]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

有没有人知道任何解决方案或修正?

Does anyone know of any solutions or fixes?

推荐答案

包括IE7 / 8在内的许多旧版浏览器都没有(完全)支持HTML 5.

Many older browsers including IE7/8 do not (fully) support HTML 5.

你可以使用 Modernizr 检测当前浏览器是否支持音频。

You can use Modernizr to detect whether the current browser supports audio.

有< a href =http://en.wikipedia.org/wiki/Polyfill =noreferrer> polyfills ,用于许多功能,包括可以添加对缺失功能的支持的音频

There are polyfills for many features including audio that can add support for missing features

https://github.com/Modernizr/Modernizr / wiki / HTML5-Cross-browser-Polyfills

(向下滚动到音频部分查看选项)

(scroll down to the Audio section for options)

polyfills适用于各种支持的浏览器和浏览器版本。

The polyfills work on a wide range of supported browsers and browser versions.

这篇关于HTML5音频无法在ie7或ie8中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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