aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/sourcebuffer/mode
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/sourcebuffer/mode
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/sourcebuffer/mode')
-rw-r--r--files/zh-cn/web/api/sourcebuffer/mode/index.html96
1 files changed, 96 insertions, 0 deletions
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
+---
+<div>{{APIRef("Media Source Extensions")}}{{SeeCompatTable}}</div>
+
+<p>{{domxref("SourceBuffer")}} 接口的 <code><strong>mode</strong></code> 属性用来控制媒体片段添加到<code>SourceBuffer</code> 时的顺序是可以任意的还是有严格顺序的。</p>
+
+<p>两个可用的值:</p>
+
+<ul>
+ <li><code>segments</code>: 媒体片段的时间戳决定段的播放顺序。这些片段可以按任意顺序添加到sourcebuffer。</li>
+ <li><code>sequence</code>: 媒体片段添加到sourcebuffer的顺序决定了它们的播放顺序。片段上的时间戳为遵守此顺序自动生成。</li>
+</ul>
+
+<p>moder的值最初是在使用mediasource.addsourcebuffer()创建sourcebuffer时设置的。如果媒体片段上已经存在时间戳,则该值将设置为<code>segments</code>;如果没有,则该值将设置为<code>sequence</code>.</p>
+
+<p>如果mode初始值为sequence想要改为segments则会引发错误, 必须以<code>sequence</code>模式维护现有段顺序。但是,可以将值从<code>segments模式</code>改为<code>sequence模式</code>。它意味着播放顺序将被固定,并会生成新的时间戳。</p>
+
+<p>当 sourceBuffer 正在处理时mode的值无法改变,如 {{domxref("SourceBuffer.appendBuffer","appendBuffer()")}} 或 {{domxref("SourceBuffer.remove","remove()")}} .</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="brush: js">var myMode = sourceBuffer.mode;
+
+sourceBuffer.mode = 'sequence';
+</pre>
+
+<h3 id="Value">Value</h3>
+
+<p>A {{domxref("DOMString")}}.</p>
+
+<h3 id="Errors">Errors</h3>
+
+<p>The following errors may be thrown when setting a new value for this property.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Error</th>
+ <th scope="col">Explanation</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>InvalidAccessError</code></td>
+ <td>An attempt was made to set the value to <code>segments</code> when the initial value is <code>sequence</code>.</td>
+ </tr>
+ <tr>
+ <td><code>InvalidStateError</code></td>
+ <td>The {{domxref("SourceBuffer")}} object is being updated (i.e. its {{domxref("SourceBuffer.updating")}} property is currently <code>true</code>), the last media segment appended to <code>this </code>SourceBuffer is incomplete, or this <code>SourceBuffer</code> has been removed from the {{domxref("MediaSource")}}.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Example">Example</h2>
+
+<p>此代码段是将sourcebuffer的模式设置为“sequence”(如果当前设置为“segments”),假如原先的播放顺序为segments.</p>
+
+<pre class="brush: js">var curMode = sourceBuffer.mode;
+if (curMode == 'segments') {
+ sourceBuffer.mode = 'sequence';
+}</pre>
+
+<h2 id="Specifications">Specifications</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('Media Source Extensions', '#widl-SourceBuffer-mode', 'mode')}}</td>
+ <td>{{Spec2('Media Source Extensions')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("api.SourceBuffer.mode")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("MediaSource")}}</li>
+ <li>{{domxref("SourceBufferList")}}</li>
+</ul>