HTMLVideoElement

HTMLVideoElement interface provides special properties and methods for manipulating video objects. It also inherits properties and methods of HTMLMediaElement and HTMLElement .

The list of supported media formats varies from one browser to the other. You should either provide your video in a single format that all the relevant browsers supports, or provide multiple video sources in enough different formats that all the browsers you need to support are covered.

特性

Inherits properties from its ancestor interfaces, HTMLMediaElement ,和 HTMLElement .

HTMLVideoElement.height
DOMString that reflects the height HTML attribute, which specifies the height of the display area, in CSS pixels.
HTMLVideoElement.poster
DOMString that reflects the poster HTML attribute, which specifies an image to show while no video data is available.
HTMLVideoElement.videoHeight 只读
Returns an unsigned integer value indicating the intrinsic height of the resource in CSS pixels, or 0 if no media is available yet.
HTMLVideoElement.videoWidth 只读
Returns an unsigned integer value indicating the intrinsic width of the resource in CSS pixels, or 0 if no media is available yet.
HTMLVideoElement.width
DOMString that reflects the width HTML attribute, which specifies the width of the display area, in CSS pixels.

Gecko-specific properties

HTMLVideoElement.mozParsedFrames 只读
Returns an unsigned long with the count of video frames that have been parsed from the media resource.
HTMLVideoElement.mozDecodedFrames 只读
Returns an unsigned long with the count of parsed video frames that have been decoded into images.
HTMLVideoElement.mozPresentedFrames 只读
Returns an unsigned long with the count of decoded frames that have been presented to the rendering pipeline for painting.
HTMLVideoElement.mozPaintedFrames 只读
Returns an unsigned long with the count of presented frames which were painted on the screen.
HTMLVideoElement.mozFrameDelay 只读
Returns an double with the time which the last painted video frame was late by, in seconds.
HTMLVideoElement.mozHasAudio 只读
返回 boolean indicating if there is some audio associated with the video.

Microsoft Extensions

HTMLVideoElement.msFrameStep()
Steps the video by one frame forward or one frame backward.
HTMLVideoElement.msHorizontalMirror
Gets or sets whether a video element is flipped horizontally in the display.
HTMLVideoElement.msInsertVideoEffect()
Inserts the specified video effect into the media pipeline.
HTMLVideoElement.msIsLayoutOptimalForPlayback 只读
Indicates whether the video can be rendered more efficiently.
HTMLVideoElement.msIsStereo3D 只读
Determines whether the system considers the loaded video source to be stereo 3-D or not. Value set to true indicates source is stereo 3D.
HTMLVideoElement.msZoom
Controls whether the video frame is trimmed to fit the video display.

方法

Inherits methods from its parent, HTMLMediaElement , and from its ancestor HTMLElement .

HTMLVideoElement.getVideoPlaybackQuality()
返回 VideoPlaybackQuality object that contains the current playback metrics. This information includes things like the number of dropped or corrupted frames, as well as the total number of frames.

Events

Inherits methods from its parent, HTMLMediaElement , and from its ancestor HTMLElement . 监听这些事件使用 addEventListener() 或通过把事件监听器赋值给 on eventname 特性为此接口。

规范

规范 状态 Comment
HTML Living Standard
The definition of 'HTMLVideoElement' in that specification.
实时标准

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLVideoElement Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
cancelVideoFrameCallback
非标
Chrome 83 Edge 83 Firefox No IE No Opera 69 Safari No WebView Android 83 Chrome Android 83 Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
getVideoPlaybackQuality
Chrome 80 Edge 12 Firefox 42
42
不支持 25 — 42
Disabled
Limited support to an allowed list of sites, for example YouTube, Netflix, and other popular streaming sites. The limitation was removed when Media Source Extensions was enabled by default in Firefox 42.
Disabled From version 25 until version 42 (exclusive): this feature is behind the media.mediasource.enabled preference. To change preferences in Firefox, visit about:config.
IE 11
11
Only works on Windows 8+.
Opera 67 Safari 8 WebView Android 80 Chrome Android 80 Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
height Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
mozDecodedFrames
弃用 非标
Chrome No Edge No Firefox 5 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 5 Opera Android No Safari iOS No Samsung Internet Android No
mozFrameDelay
弃用 非标
Chrome No Edge No Firefox 5 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 5 Opera Android No Safari iOS No Samsung Internet Android No
mozHasAudio
弃用 非标
Chrome No Edge No Firefox 15 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 15 Opera Android No Safari iOS No Samsung Internet Android No
mozPaintedFrames
弃用 非标
Chrome No Edge No Firefox 5 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 5 Opera Android No Safari iOS No Samsung Internet Android No
mozParsedFrames
弃用 非标
Chrome No Edge No Firefox 5 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 5 Opera Android No Safari iOS No Samsung Internet Android No
mozPresentedFrames
弃用 非标
Chrome No Edge No Firefox 5 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 5 Opera Android No Safari iOS No Samsung Internet Android No
msIsStereo3D
非标
Chrome No Edge 12 — 79 Firefox No IE 10 Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
poster Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
requestVideoFrameCallback
非标
Chrome 83 Edge 83 Firefox No IE No Opera 69 Safari No WebView Android 83 Chrome Android 83 Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
videoHeight Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
videoWidth Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
width Chrome Yes Edge 12 Firefox 4 IE 9 Opera 10.5 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
用户必须明确启用此特征。

另请参阅

  1. HTMLVideoElement
  2. 特性
    1. msHorizontalMirror
    2. msIsLayoutOptimalForPlayback
    3. msIsStereo3D
    4. msZoom
    5. videoHeight
    6. videoWidth
  3. 方法
    1. getVideoPlaybackQuality()
    2. msFrameStep()
    3. msInsertVideoEffect()
  4. 继承:
    1. HTMLMediaElement
    2. HTMLElement
    3. Element
    4. Node
    5. EventTarget
  5. Related pages for HTML DOM
    1. BeforeUnloadEvent
    2. DOMStringMap
    3. ErrorEvent
    4. GlobalEventHandlers
    5. HTMLAnchorElement
    6. HTMLAreaElement
    7. HTMLAudioElement
    8. HTMLBRElement
    9. HTMLBaseElement
    10. HTMLBaseFontElement
    11. HTMLBodyElement
    12. HTMLButtonElement
    13. HTMLCanvasElement
    14. HTMLContentElement
    15. HTMLDListElement
    16. HTMLDataElement
    17. HTMLDataListElement
    18. HTMLDialogElement
    19. HTMLDivElement
    20. HTMLDocument
    21. HTMLElement
    22. HTMLEmbedElement
    23. HTMLFieldSetElement
    24. HTMLFormControlsCollection
    25. HTMLFormElement
    26. HTMLFrameSetElement
    27. HTMLHRElement
    28. HTMLHeadElement
    29. HTMLHeadingElement
    30. HTMLHtmlElement
    31. HTMLIFrameElement
    32. HTMLImageElement
    33. HTMLInputElement
    34. HTMLIsIndexElement
    35. HTMLKeygenElement
    36. HTMLLIElement
    37. HTMLLabelElement
    38. HTMLLegendElement
    39. HTMLLinkElement
    40. HTMLMapElement
    41. HTMLMediaElement
    42. HTMLMetaElement
    43. HTMLMeterElement
    44. HTMLModElement
    45. HTMLOListElement
    46. HTMLObjectElement
    47. HTMLOptGroupElement
    48. HTMLOptionElement
    49. HTMLOptionsCollection
    50. HTMLOutputElement
    51. HTMLParagraphElement
    52. HTMLParamElement
    53. HTMLPictureElement
    54. HTMLPreElement
    55. HTMLProgressElement
    56. HTMLQuoteElement
    57. HTMLScriptElement
    58. HTMLSelectElement
    59. HTMLShadowElement
    60. HTMLSourceElement
    61. HTMLSpanElement
    62. HTMLStyleElement
    63. HTMLTableCaptionElement
    64. HTMLTableCellElement
    65. HTMLTableColElement
    66. HTMLTableDataCellElement
    67. HTMLTableElement
    68. HTMLTableHeaderCellElement
    69. HTMLTableRowElement
    70. HTMLTableSectionElement
    71. HTMLTemplateElement
    72. HTMLTextAreaElement
    73. HTMLTimeElement
    74. HTMLTitleElement
    75. HTMLTrackElement
    76. HTMLUListElement
    77. HTMLUnknownElement
    78. HashChangeEvent
    79. History
    80. ImageData
    81. Location
    82. MessageChannel
    83. MessageEvent
    84. MessagePort
    85. Navigator
    86. NavigatorGeolocation
    87. NavigatorID
    88. NavigatorLanguage
    89. NavigatorOnLine
    90. NavigatorPlugins
    91. PageTransitionEvent
    92. Plugin
    93. PluginArray
    94. PopStateEvent
    95. PortCollection
    96. PromiseRejectionEvent
    97. RadioNodeList
    98. Transferable
    99. ValidityState
    100. Window
    101. WindowBase64
    102. WindowEventHandlers
    103. WindowTimers