Audio controlsProperty

Audio 对象参考手册Audio Object

Examples

Enable controls for audio:

document.getElementById("myAudio").controls = true;

Try it Yourself »

Definition and Usage

The controls property sets or returns whether the browser should display standard audio/video controls.

This property reflects the <audio > controls attribute.

If the property is present, it specifies the display mode of the audio controls.

Audio/video controls include:

  • Play
  • Pause
  • Progress bar
  • Volume

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the controls property.

Note:Internet Explorer 8 or earlier browsers do not support the <audio> element.


Syntax

Return the controls property:

audioObject.controls

Set the controls property:

audioObject.controls=true|false

Property Values

Value Description
true|false Specifies whether the audio should display controls.
  • true - Specifies that controls are displayed.
  • false - Default. Specifies that controls are not displayed.

Technical Details

Return Value: A Boolean value, returns true if the audio is set to display controls, otherwise returns false.
Default Value: false 


More Examples

Example

Check whether audio controls are displayed:

var x = document.getElementById("myAudio").controls;
xThe output result is:
true

Try it Yourself »


Related Articles

HTML Reference Manual:HTML <audio> controls Attribute


Audio 对象参考手册Audio Object Other Extensions