Video controls 属性

定义和用法

controls 属性设置或返回视频是否应显示标准视频控件。

此属性表示 <video> controls 属性

如果设置该属性,它规定应显示视频控件。

视频控件应包括:

  • 播放
  • 暂停
  • 检索
  • 音量
  • 全屏切换
  • 字幕(可用时)
  • 轨道(可用时)

实例

例子 1

启用视频控件:

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

亲自试一试

例子 2

查看是否显示视频控件:

var x = document.getElementById("myVideo").controls;

亲自试一试

例子 3

启用、禁用以及检查控件状态:

var x = document.getElementById("myVideo");
function enableControls() { 
  x.controls = true;
  x.load();
} 
function disableControls() { 
  x.controls = false;
  x.load();
} 
function checkControls() { 
  alert(x.controls);
}

亲自试一试

语法

返回 controls 属性:

videoObject.controls

设置 controls 属性:

videoObject.controls = true|false

属性值

描述
true|false

Magaaral kung ang kontrol ng video ay dapat ipakita o hindi.

  • true - Indicates that the control is displayed
  • false - Default. Indicates that the control is not displayed

Technical Details

Return Value: Boolean value, returns true if the video control is displayed; otherwise returns false.
Default Value: false

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 9.0 Support Support Support

Related Pages

HTML Reference Manual:HTML <video> controls Atingtang