Html 音频标签在 IE9 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7358689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:32:21  来源:igfitidea点击:

audio tag not working in IE9

htmlinternet-explorer-9html5-audio

提问by robertc

I'm experimenting with the audio tag.

我正在试验音频标签。

The file below does work in Google Chrome, but not in IE9. I'm always getting "audio tag not supported". I also tried wav, flac, wma --> same result.

下面的文件在谷歌浏览器中有效,但在 IE9 中无效。我总是收到“不支持音频标签”。我也试过 wav、flac、wma --> 相同的结果。

I suspect there might some issue with the compaitibility mode, but I don't find where to change it.

我怀疑兼容模式可能存在一些问题,但我找不到更改它的位置。

Can anyone help? Kind regards Georg

任何人都可以帮忙吗?亲切的问候乔治

<html>
  <head>
  </head>
  <body>
    <audio controls="controls" src="c:\concerto.mp3" >
       audio tag not supported.
    </audio>            
  </body>
</html>

回答by robertc

Add the HTML5 doctype to the page and it should trigger standards mode in IE9. You should also add a title element to make the document valid:

将 HTML5 doctype 添加到页面,它应该在 IE9 中触发标准模式。您还应该添加一个 title 元素以使文档有效

<!DOCTYPE html>
<html>
  <head>
    <title>Add a title</title>
  </head>
  <body>
    <audio controls="controls" src="c:\concerto.mp3" >
       audio tag not supported.
    </audio>            
  </body>
</html>

If you're still having trouble, try adding this meta tag to the head:

如果您仍然遇到问题,请尝试将此元标记添加到头部:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

回答by michael gold

If 'audio' is working in chrome, safari, etc. but not in IE, check your meta tags. I had one that referred to IE8 which stopped the 'audio' from functioning. It was quite frustrating until I found the problem at which point the lights went on.

如果“音频”在 chrome、safari 等中有效,但在 IE 中无效,请检查您的元标记。我有一个提到 IE8,它阻止了“音频”的运行。直到我发现问题时,灯才亮起来,这真是令人沮丧。

回答by Mani

IE plays files in your PC if you give full path as as a URL "file://c:/concert.mp3" or only file name "concert.mp3" if the file is in the same folder as the html file. Firefox also requires full path for files in other folders while Chrome seems to add 'file://' if it is not in the URL. This is a problem if you want to use the to play local files if they are in other folders. The FileAPI does not allow you to find the path of the file.

如果您将完整路径作为 URL“file://c:/concert.mp3”或仅文件名“concert.mp3”(如果文件与 html 文件位于同一文件夹中),则 IE 会在您的 PC 中播放文件。Firefox 还需要其他文件夹中文件的完整路径,而 Chrome 似乎添加了“file://”,如果它不在 URL 中。如果您想使用 播放本地文件(如果它们位于其他文件夹中),则这是一个问题。FileAPI 不允许您找到文件的路径。