From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/sourcebuffer/mode/index.html | 96 ++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 files/zh-cn/web/api/sourcebuffer/mode/index.html (limited to 'files/zh-cn/web/api/sourcebuffer/mode/index.html') diff --git a/files/zh-cn/web/api/sourcebuffer/mode/index.html b/files/zh-cn/web/api/sourcebuffer/mode/index.html new file mode 100644 index 0000000000..369280a54e --- /dev/null +++ b/files/zh-cn/web/api/sourcebuffer/mode/index.html @@ -0,0 +1,96 @@ +--- +title: SourceBuffer.mode +slug: Web/API/SourceBuffer/mode +translation_of: Web/API/SourceBuffer/mode +--- +
{{APIRef("Media Source Extensions")}}{{SeeCompatTable}}
+ +

{{domxref("SourceBuffer")}} 接口的 mode 属性用来控制媒体片段添加到SourceBuffer 时的顺序是可以任意的还是有严格顺序的。

+ +

两个可用的值:

+ + + +

moder的值最初是在使用mediasource.addsourcebuffer()创建sourcebuffer时设置的。如果媒体片段上已经存在时间戳,则该值将设置为segments;如果没有,则该值将设置为sequence.

+ +

如果mode初始值为sequence想要改为segments则会引发错误, 必须以sequence模式维护现有段顺序。但是,可以将值从segments模式改为sequence模式。它意味着播放顺序将被固定,并会生成新的时间戳。

+ +

当 sourceBuffer 正在处理时mode的值无法改变,如 {{domxref("SourceBuffer.appendBuffer","appendBuffer()")}} 或 {{domxref("SourceBuffer.remove","remove()")}} .

+ +

Syntax

+ +
var myMode = sourceBuffer.mode;
+
+sourceBuffer.mode = 'sequence';
+
+ +

Value

+ +

A {{domxref("DOMString")}}.

+ +

Errors

+ +

The following errors may be thrown when setting a new value for this property.

+ + + + + + + + + + + + + + + + + + +
ErrorExplanation
InvalidAccessErrorAn attempt was made to set the value to segments when the initial value is sequence.
InvalidStateErrorThe {{domxref("SourceBuffer")}} object is being updated (i.e. its {{domxref("SourceBuffer.updating")}} property is currently true), the last media segment appended to this SourceBuffer is incomplete, or this SourceBuffer has been removed from the {{domxref("MediaSource")}}.
+ +

Example

+ +

此代码段是将sourcebuffer的模式设置为“sequence”(如果当前设置为“segments”),假如原先的播放顺序为segments.

+ +
var curMode = sourceBuffer.mode;
+if (curMode == 'segments') {
+  sourceBuffer.mode = 'sequence';
+}
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Media Source Extensions', '#widl-SourceBuffer-mode', 'mode')}}{{Spec2('Media Source Extensions')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.SourceBuffer.mode")}}

+
+ +

See also

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