The HTMLAudioElement
interface provides access to the properties of <audio>
elements, as well as methods to manipulate them. It derives from the HTMLMediaElement
interface.
No specific property; inherits properties from its parent, HTMLMediaElement
, and from HTMLElement
.
Inherits methods from its parent, HTMLMediaElement
, and from HTMLElement
.
mySound = new Audio([URLString]);
Constructor for audio elements. The preload
property of the returned object is set to auto
and the src
property is set to the argument value. The browser begins asynchronously selecting the resource before returning the object.
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)src
property of the constructed HTMLAudioElement
.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. |
| 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 The definition of 'HTMLAudioElement' in that specification. | Living Standard | No change from HTML5 |
HTML5 The definition of 'HTMLAudioElement' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 3.5 (1.9.1) | (Yes) | (Yes) | (Yes) |
mozSetup() , mozCurrentSampleOffset() , mozWriteAudio()
| No support | No support | 4.0 (2.0) | No support | No support | No support |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | 1.0 (1.9.1) | (Yes) | (Yes) | (Yes) |
mozSetup() , mozCurrentSampleOffset() , mozWriteAudio()
| No support | No support | 4.0 (2.0) | No support | No support | No support |
<audio>
.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement