HTMLMediaElement: pause event

翻译不完整。 请帮助我们翻译这篇文章!

当暂停媒体播放时 pause 事件触发, 并且媒体进入暂停状态,最常见的是通过pause()方法来触发。 当pause() 触发时pause状态只改变1次,并且媒体的pause变成 true

General info

Bubbles No
Cancelable No
Interface Event
Target Element
Default Action None
Event handler property GlobalEventHandlers.onpause
Specification HTML5 media

例子

下面例子给媒体添加 pause 事件监听handler,然后事件发生时会给handler发送一个提醒信息

使用 addEventListener():

const video = document.querySelector('video');

video.addEventListener('pause', (event) => {
  console.log('The Boolean paused property is now true. Either the ' + 
  'pause() method was called or the autoplay attribute was toggled.');
});

使用 onpause 事件监听属性:

const video = document.querySelector('video');

video.onpause = (event) => {
  console.log('The Boolean paused property is now true. Either the ' + 
  'pause() method was called or the autoplay attribute was toggled.');
};

说明

Specification Status
HTML Living Standard
pause media event
Living Standard
HTML5
pause media event
Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
pause eventChrome Full support 3Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support YesChrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0

Legend

Full support  
Full support

相关事件

See also