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/load | |
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/load')
-rw-r--r-- | files/zh-cn/web/api/htmlmediaelement/load/index.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlmediaelement/load/index.html b/files/zh-cn/web/api/htmlmediaelement/load/index.html new file mode 100644 index 0000000000..eb674466d9 --- /dev/null +++ b/files/zh-cn/web/api/htmlmediaelement/load/index.html @@ -0,0 +1,74 @@ +--- +title: HTMLMediaElement.load() +slug: Web/API/HTMLMediaElement/load +translation_of: Web/API/HTMLMediaElement/load +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p><span class="seoSummary"> <code><strong>load()</strong></code> 方法重置媒体成初始化状态,选择一个播放源, 为载入媒体重新播放做准备。</span> 媒体预播放的信息是由 <span class="seoSummary"><code><strong>preload</strong></code></span> 这个参数决定的。</p> + +<p>此方法只在对媒体做动态更改时管用,要么更改<code>src</code>属性,要么添加或删除<code>source</code> 。 <code>load()</code> 将会重置元素重新扫描可用的源,从而让改动生效。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>mediaElement</em>.load();</pre> + +<h3 id="参数">参数</h3> + +<p>None.</p> + +<h3 id="返回值">返回值</h3> + +<p><code>undefined</code>.</p> + +<h2 id="用法">用法</h2> + +<p>调用 <code>load()</code> 会使媒体上所有正在进行的操作中止,然后根据 <code>audio</code> 或者 <code>video</code> 元素的 <code>src</code> 或者 <code>source</code> 属性里寻找合适的播放源并重新加载媒体内容。 更多查看 <a href="https://wiki.developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content#Supporting_multiple_formats" title="And that's a wrap; we hope you had fun playing with video and audio in web pages! In the next article, we'll look at other ways of embedding content on the Web, using technologies like <iframe> and <object>.">Supporting multiple formats</a> 和 <a href="https://wiki.developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content" title="And that's a wrap; we hope you had fun playing with video and audio in web pages! In the next article, we'll look at other ways of embedding content on the Web, using technologies like <iframe> and <object>.">Video and audio content</a> 。</p> + +<p>The process of aborting any ongoing activities will cause any outstanding {{jsxref("Promise")}}s returned by {{domxref("HTMLMediaElement.play", "play()")}} being resolved or rejected as appropriate based on their status before the loading of new media can begin. Pending play promises are aborted with an <code>"AbortError"</code> {{domxref("DOMException")}}.</p> + +<p>在load过程中 合适的事件会发生并通知给媒体本身,包括:</p> + +<ul> + <li>如果已经是 <code>load</code> 过了,则 <code>abort</code> 事件发送给媒体。</li> + <li>If the element has already been initialized with media, the <strong>{{event("emptied")}}</strong> event is sent.</li> + <li>如果重置播放位置到开始,通常指修改播放位置,<strong>timeupdate</strong> 事件触发。</li> + <li>当已经选择了源并且已经准备加载内容了,<strong>loadstart</strong> 事件触发。</li> + <li>之前的几点,媒体加载并且事件已经送达</li> +</ul> + +<h2 id="例子">例子</h2> + +<p>例子中有一个 {{HTMLElement("video")}} 元素然后重置它 <code>load()</code>.</p> + +<pre class="brush: js">var mediaElem = document.querySelector("video"); +mediaElem.load(); +</pre> + +<h2 id="说明">说明</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', "media.html#dom-media-load", "HTMLMediaElement.load()")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', "semantics-embedded-content.html#dom-htmlmediaelement-load", "HTMLMediaElement.load()")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.HTMLMediaElement.load")}}</p> |