aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html')
-rw-r--r--files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html123
1 files changed, 123 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html b/files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html
new file mode 100644
index 0000000000..a0fdca7df3
--- /dev/null
+++ b/files/zh-cn/web/api/htmlcanvaselement/capturestream/index.html
@@ -0,0 +1,123 @@
+---
+title: HTMLCanvasElement.captureStream()
+slug: Web/API/HTMLCanvasElement/captureStream
+translation_of: Web/API/HTMLCanvasElement/captureStream
+original_slug: Web/API/HTMLCanvasElement/捕获流
+---
+<div>{{APIRef("Media Capture and Streams")}}{{SeeCompatTable}}</div>
+
+<p>该 <code><strong>HTMLCanvasElement</strong></code><strong><code>.captureStream()</code></strong> 方法返回的 {{domxref("CanvasCaptureMediaStream")}} 是一个实时视频捕获的画布。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><var>MediaStream</var> = <var>canvas</var>.captureStream(<var>frameRate</var>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>frameRate</code> 可选</dt>
+ <dd><font><font>设置双精准度浮点值为每个帧的捕获速率。</font><font>如果未设置,则每次画布更改时都会捕获一个新帧。</font><font>如果设置为</font></font><code>0</code><font><font>,则会捕获单个帧。</font></font></dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>对一个 {{domxref("MediaStream")}} <font>对象</font><font>的引用</font>.</p>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js"><code>//</code>获取所需要截取媒体流的canvas element
+var canvasElt = document.querySelector('canvas');
+
+//<code>截取到媒体流</code>
+var stream = canvasElt.captureStream(25); // 25 FPS
+
+//使用媒体流
+// E.g.使用RTCPeerConnection来传输给其它的电脑
+// 下面的pc是其他地方创建的一个RTCPeerConnection
+pc.addStream(stream);
+</pre>
+
+<h2 id="产品规格">产品规格</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('Media Capture DOM Elements', '#widl-HTMLCanvasElement-captureStream-CanvasCaptureMediaStream-double-frameRate', 'HTMLCanvasElement.captureStream()')}}</td>
+ <td>{{Spec2('Media Capture DOM Elements')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ <td>{{CompatGeckoDesktop(43)}}<sup>[1]</sup></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatOpera(36.0)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ <td>{{CompatGeckoMobile(43)}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatOpera(38)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] <font>在Firefox 41和42中,此功能默认是禁用的; </font><font>将首选项</font> <code>canvas.capturestream.enabled</code> 设置 <code>true</code> 。</p>
+
+<h2 id="看看其他">看看其他</h2>
+
+<ul>
+ <li>{{domxref("CanvasCaptureMediaStream")}},所属接口.</li>
+ <li>{{domxref("HTMLMediaElement.captureStream()")}}, 允许从一个媒体中获取流</li>
+ <li>{{domxref("MediaStream")}}</li>
+ <li>{{domxref("Media Capture and Streams API")}}</li>
+</ul>