From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../zh-cn/web/api/htmlmediaelement/load/index.html | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 files/zh-cn/web/api/htmlmediaelement/load/index.html (limited to 'files/zh-cn/web/api/htmlmediaelement/load') 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 +--- +
{{APIRef("HTML DOM")}}
+ +

 load() 方法重置媒体成初始化状态,选择一个播放源, 为载入媒体重新播放做准备。 媒体预播放的信息是由 preload 这个参数决定的。

+ +

此方法只在对媒体做动态更改时管用,要么更改src属性,要么添加或删除source 。 load() 将会重置元素重新扫描可用的源,从而让改动生效。

+ +

语法

+ +
mediaElement.load();
+ +

参数

+ +

None.

+ +

返回值

+ +

undefined.

+ +

用法

+ +

调用 load() 会使媒体上所有正在进行的操作中止,然后根据 audio 或者 video 元素的 src 或者 source 属性里寻找合适的播放源并重新加载媒体内容。 更多查看  Supporting multiple formats 和 Video and audio content 。

+ +

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 "AbortError" {{domxref("DOMException")}}.

+ +

在load过程中 合适的事件会发生并通知给媒体本身,包括:

+ + + +

例子

+ +

例子中有一个 {{HTMLElement("video")}} 元素然后重置它 load().

+ +
var mediaElem = document.querySelector("video");
+mediaElem.load();
+
+ +

说明

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "media.html#dom-media-load", "HTMLMediaElement.load()")}}{{Spec2('HTML WHATWG')}}Initial definition.
{{SpecName('HTML5 W3C', "semantics-embedded-content.html#dom-htmlmediaelement-load", "HTMLMediaElement.load()")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

浏览器兼容性

+ + + +

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

-- cgit v1.2.3-54-g00ecf