翻译不完整。 请帮助我们翻译这篇文章!


HTMLAudioElement 接口提供访问<audio> 元素的接口, 像方法一操作. 来源于 HTMLMediaElement 接口. 


没有特别的属性,继承于他的父元素, HTMLMediaElement, and from HTMLElement.


没有特别的方法,继承于他的父元素 HTMLMediaElement, and from HTMLElement.



mySound = new Audio([URLString]);


audio元素的构造器。返回对象的 preload 属性 将会被设置成 auto ,而它的 src 属性将会被设置为 URLString. 浏览器返回 Audio 对象之前会开始异步的获得audio资源。

Note: An Audio element constructed with new Audio() won't be garbage collected as long as playback is in progress. It will continue playing and be audible until pause() is called or playback finishes.


URLString (expected type: DOMString; optional)
The src property of the constructed HTMLAudioElement.

Regular methods

Name & Arguments Return Description
mozCurrentSampleOffset() unsigned long long Indicates the current offset of the audio stream that was created by a call to mozWriteAudio(). This offset is specified as the number of samples since the beginning of the stream.

mozSetup(in PRUint32 channels, in PRUint32 rate)

void Sets up the audio stream for writing. You specify as parameters the number of channels (1 for mono or 2 for stereo), then the sampling rate (44100 for 44.1kHz, for example).
mozWriteAudio(in jsval data) unsigned long Writes audio into the stream at the current offset. Returns the number of bytes actually written to the stream.


Specification Status Comment
HTML Living Standard
Living Standard No change from HTML5
Recommendation Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) 3.5 (1.9.1) (Yes) (Yes) (Yes)
mozSetup(), mozCurrentSampleOffset(), mozWriteAudio() 未实现 4.0 (2.0) 未实现 未实现 未实现
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.9.1) (Yes) (Yes) (Yes)
mozSetup(), mozCurrentSampleOffset(), mozWriteAudio() 未实现 4.0 (2.0) 未实现 未实现 未实现

See also

  • HTML element implementing this interface: <audio>.