From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/htmlmediaelement/pause_event/index.html | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 files/zh-cn/web/api/htmlmediaelement/pause_event/index.html (limited to 'files/zh-cn/web/api/htmlmediaelement/pause_event') diff --git a/files/zh-cn/web/api/htmlmediaelement/pause_event/index.html b/files/zh-cn/web/api/htmlmediaelement/pause_event/index.html new file mode 100644 index 0000000000..824f4bb5ff --- /dev/null +++ b/files/zh-cn/web/api/htmlmediaelement/pause_event/index.html @@ -0,0 +1,127 @@ +--- +title: 'HTMLMediaElement: pause event' +slug: Web/API/HTMLMediaElement/pause_event +translation_of: Web/API/HTMLMediaElement/pause_event +--- +
{{APIRef("HTMLMediaElement")}}
+ +
+ +

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

+ +

General info

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BubblesNo
CancelableNo
Interface{{DOMxRef("Event")}}
TargetElement
Default ActionNone
Event handler property{{domxref("GlobalEventHandlers.onpause")}}
SpecificationHTML5 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.');
+};
+ +

说明

+ + + + + + + + + + + + + + + + + + +
SpecificationStatus
{{SpecName('HTML WHATWG', "media.html#event-media-pause", "pause media event")}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#event-media-pause", "pause media event")}}{{Spec2('HTML5 W3C')}}
+ +

浏览器兼容性

+ + + +

{{Compat("api.HTMLMediaElement.pause_event")}}

+ +

相关事件

+ + + +

See also

+ + -- cgit v1.2.3-54-g00ecf