diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlmediaelement/pause_event | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlmediaelement/pause_event')
-rw-r--r-- | files/zh-cn/web/api/htmlmediaelement/pause_event/index.html | 127 |
1 files changed, 127 insertions, 0 deletions
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 +--- +<div>{{APIRef("HTMLMediaElement")}}</div> + +<div></div> + +<p><span class="seoSummary">当暂停媒体播放时 <code>pause</code> 事件触发, 并且媒体进入暂停状态,最常见的是通过<code>pause()</code>方法来触发。</span> 当<code>pause()</code> 触发时<code>pause</code>状态只改变1次,并且媒体的<code>pause</code>变成 <code>true</code>。</p> + +<h2 id="General_info">General info</h2> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">Bubbles</th> + <td>No</td> + </tr> + <tr> + <th scope="row">Cancelable</th> + <td>No</td> + </tr> + <tr> + <th scope="row">Interface</th> + <td>{{DOMxRef("Event")}}</td> + </tr> + <tr> + <th scope="row">Target</th> + <td>Element</td> + </tr> + <tr> + <th scope="row">Default Action</th> + <td>None</td> + </tr> + <tr> + <th scope="row">Event handler property</th> + <td>{{domxref("GlobalEventHandlers.onpause")}}</td> + </tr> + <tr> + <th scope="row">Specification</th> + <td><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-playing">HTML5 media</a></td> + </tr> + </tbody> +</table> + +<h2 id="例子">例子</h2> + +<p>下面例子给媒体添加 <code>pause</code> 事件监听handler,然后事件发生时会给handler发送一个提醒信息</p> + +<p>使用 <code>addEventListener():</code></p> + +<pre class="brush: js">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.'); +});</pre> + +<p>使用 <code>onpause</code> 事件监听属性:</p> + +<pre class="brush: js">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.'); +};</pre> + +<h2 id="说明">说明</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', "media.html#event-media-pause", "pause media event")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', "embedded-content-0.html#event-media-pause", "pause media event")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.HTMLMediaElement.pause_event")}}</p> + +<h2 id="相关事件">相关事件</h2> + +<ul> + <li>{{domxref("HTMLMediaElement.playing_event", 'HTMLMediaElement: playing event')}}</li> + <li>{{domxref("HTMLMediaElement.waiting_event", 'HTMLMediaElement: waiting event')}}</li> + <li>{{domxref("HTMLMediaElement.seeking_event", 'HTMLMediaElement: seeking event')}}</li> + <li>{{domxref("HTMLMediaElement.seeked_event", 'HTMLMediaElement: seeked event')}}</li> + <li>{{domxref("HTMLMediaElement.ended_event", 'HTMLMediaElement: ended event')}}</li> + <li>{{domxref("HTMLMediaElement.loadedmetadata_event", 'HTMLMediaElement: loadedmetadata event')}}</li> + <li>{{domxref("HTMLMediaElement.loadeddata_event", 'HTMLMediaElement: loadeddata event')}}</li> + <li>{{domxref("HTMLMediaElement.canplay_event", 'HTMLMediaElement: canplay event')}}</li> + <li>{{domxref("HTMLMediaElement.canplaythrough_event", 'HTMLMediaElement: canplaythrough event')}}</li> + <li>{{domxref("HTMLMediaElement.durationchange_event", 'HTMLMediaElement: durationchange event')}}</li> + <li>{{domxref("HTMLMediaElement.timeupdate_event", 'HTMLMediaElement: timeupdate event')}}</li> + <li>{{domxref("HTMLMediaElement.play_event", 'HTMLMediaElement: play event')}}</li> + <li>{{domxref("HTMLMediaElement.pause_event", 'HTMLMediaElement: pause event')}}</li> + <li>{{domxref("HTMLMediaElement.ratechange_event", 'HTMLMediaElement: ratechange event')}}</li> + <li>{{domxref("HTMLMediaElement.volumechange_event", 'HTMLMediaElement: volumechange event')}}</li> + <li>{{domxref("HTMLMediaElement.suspend_event", 'HTMLMediaElement: suspend event')}}</li> + <li>{{domxref("HTMLMediaElement.emptied_event", 'HTMLMediaElement: emptied event')}}</li> + <li>{{domxref("HTMLMediaElement.stalled_event", 'HTMLMediaElement: stalled event')}}</li> +</ul> + +<h2 id="See_also">See also</h2> + +<ul> + <li>{{domxref("HTMLAudioElement")}}</li> + <li>{{domxref("HTMLVideoElement")}}</li> + <li>{{HTMLElement("audio")}}</li> + <li>{{HTMLElement("video")}}</li> + <li>{{domxref("SpeechSynthesisUtterance")}}</li> +</ul> |