Audio preloadProperty

Audio 对象参考手册Audio Object

Example

Start loading the audio as soon as the page loads:

var x = document.getElementById("myAudio").preload;
xThe output is:
none // The audio is not loaded when the page loads

Try it yourself »

Definition and Usage

The preload property sets or returns whether the audio should be loaded immediately after the page loads.

The preload property describes whether the audio is preloaded after the page loads.

Note:If the autoplay attribute is used, the preload attribute is ignored.

Note:The <audio> element is new in HTML5.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the preload attribute.

Note:Internet Explorer does not support the preload attribute.


Syntax

Return the preload property:

audioObject.preload

Set the preload property:

audioObject.preload="auto|metadata|none"

Property Values

Value Description
auto Indicates that the audio should start loading as soon as the page loads.
metadata Indicates that only metadata about the audio should be loaded after the page loads.
none Indicates that the audio should not be loaded after the page loads.

Technical Details

Return Value: A string representing the preloaded data. Possible return values are "auto", "metadata", or "none". You can see what the "property values" represent.


More Examples

Example

The following example demonstrates how to set different property values:

document.getElementById("myAudio").preload="none";
document.getElementById("myaudio").preload="auto";

Try it yourself »


Related Pages

HTML Reference Manual:HTML <audio> preload Attribute


Audio 对象参考手册Audio Object Other Extensions