Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 412325 of HTMLAudioElement

  • Revision slug: Web/API/HTMLAudioElement
  • Revision title: HTMLAudioElement
  • Revision id: 412325
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{DOMRef}}{{gecko_minversion_header("1.9.1")}}
The HTMLAudioElement interface provides access to the properties of {{HTMLElement("audio")}} elements, as well as methods to manipulate them. It's derived from the HTMLMediaElement interface

Properties

No specific property; inherits properties from its parent, {{domxref("HTMLMediaElement")}}, and from {{domxref("HTMLElement")}}.

Methods

Inherits methods from its parent, {{domxref("HTMLMediaElement")}}, and from {{domxref("HTMLElement")}}.

Constructor

Syntax

mySound = new Audio([URLString]);

Description

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.

Parameters

Regular methods

URLString (expected type: {{domxref("DOMString")}}; optional)
The src property of the constructed HTMLAudioElement.
Name & Arguments Return Description
mozCurrentSampleOffset() {{gecko_minversion_inline("2.0")}} {{non-standard_inline}} 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) {{gecko_minversion_inline("2.0")}} {{non-standard_inline}}

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) {{gecko_minversion_inline("2.0")}} {{non-standard_inline}} unsigned long Writes audio into the stream at the current offset. Returns the number of bytes actually written to the stream.

See also

  • HTML element implementing this interface: {{HTMLElement("audio")}}.

Revision Source

<div>
  {{DOMRef}}{{gecko_minversion_header("1.9.1")}}</div>
<div>
  The <code>HTMLAudioElement</code> interface provides access to the properties of {{HTMLElement("audio")}} elements, as well as methods to manipulate them. It's derived from the <a href="/en-US/docs/DOM/HTMLMediaElement" title="DOM/HTMLMediaElement"><code>HTMLMediaElement</code></a> interface</div>
<h2 id="Properties" name="Properties">Properties</h2>
<p><em>No specific property; inherits properties from its parent, {{domxref("HTMLMediaElement")}}, and from {{domxref("HTMLElement")}}.</em></p>
<h2 id="Methods" name="Methods">Methods</h2>
<p><em>Inherits methods from its parent, {{domxref("HTMLMediaElement")}}, and from {{domxref("HTMLElement")}}.</em></p>
<h3 id="Constructor">Constructor</h3>
<h4 id="Syntax">Syntax</h4>
<pre class="syntaxbox">
mySound = new Audio([<em>URLString</em>]);
</pre>
<h4 id="Description">Description</h4>
<p>Constructor for audio elements. The <code>preload</code> property of the returned object is set to <code>auto</code> and the <code>src</code> property is set to the argument value. The browser begins <em>asynchronously</em> selecting the resource before returning the object.</p>
<h4 id="Parameters">Parameters</h4>
<h3 id="Regular_methods">Regular methods</h3>
<dl>
  <dt>
    <code>URLString</code> (expected type: {{domxref("DOMString")}}; optional)</dt>
  <dd>
    The <code>src</code> property of the constructed <code>HTMLAudioElement</code>.</dd>
</dl>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Name &amp; Arguments</th>
      <th scope="col">Return</th>
      <th scope="col">Description</th>
    </tr>
    <tr>
      <td><code>mozCurrentSampleOffset()</code> {{gecko_minversion_inline("2.0")}} {{non-standard_inline}}</td>
      <td>unsigned long long</td>
      <td>Indicates the current offset of the audio stream that was created by a call to <code>mozWriteAudio()</code>. This offset is specified as the number of samples since the beginning of the stream.</td>
    </tr>
    <tr>
      <td>
        <p><code>mozSetup(in PRUint32 channels, in PRUint32 rate)</code> {{gecko_minversion_inline("2.0")}} {{non-standard_inline}}</p>
      </td>
      <td>void</td>
      <td>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).</td>
    </tr>
    <tr>
      <td><code>mozWriteAudio(in jsval data)</code> {{gecko_minversion_inline("2.0")}} {{non-standard_inline}}</td>
      <td>unsigned long</td>
      <td>Writes audio into the stream at the current offset. Returns the number of bytes actually written to the stream.</td>
    </tr>
  </tbody>
</table>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>HTML element implementing this interface: {{HTMLElement("audio")}}.</li>
</ul>
Revert to this revision