stream.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <!doctype html>
  2. <html class="default no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>Stream | @urtc/sdk-web</title>
  7. <meta name="description" content="Documentation for @urtc/sdk-web">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link rel="stylesheet" href="../assets/css/main.css">
  10. </head>
  11. <body>
  12. <header>
  13. <div class="tsd-page-toolbar">
  14. <div class="container">
  15. <div class="table-wrap">
  16. <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
  17. <div class="field">
  18. <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
  19. <input id="tsd-search-field" type="text" />
  20. </div>
  21. <ul class="results">
  22. <li class="state loading">Preparing search index...</li>
  23. <li class="state failure">The search index is not available</li>
  24. </ul>
  25. <a href="../index.html" class="title">@urtc/sdk-web</a>
  26. </div>
  27. <div class="table-cell" id="tsd-widgets">
  28. <div id="tsd-filter">
  29. <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
  30. <div class="tsd-filter-group">
  31. <div class="tsd-select" id="tsd-filter-visibility">
  32. <span class="tsd-select-label">All</span>
  33. <ul class="tsd-select-list">
  34. <li data-value="public">Public</li>
  35. <li data-value="protected">Public/Protected</li>
  36. <li data-value="private" class="selected">All</li>
  37. </ul>
  38. </div>
  39. <input type="checkbox" id="tsd-filter-inherited" checked />
  40. <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
  41. <input type="checkbox" id="tsd-filter-externals" checked />
  42. <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
  43. </div>
  44. </div>
  45. <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="tsd-page-title">
  51. <div class="container">
  52. <ul class="tsd-breadcrumb">
  53. <li>
  54. <a href="../index.html">Globals</a>
  55. </li>
  56. <li>
  57. <a href="stream.html">Stream</a>
  58. </li>
  59. </ul>
  60. <h1>Class Stream</h1>
  61. </div>
  62. </div>
  63. </header>
  64. <div class="container container-main">
  65. <div class="row">
  66. <div class="col-8 col-content">
  67. <section class="tsd-panel tsd-comment">
  68. <div class="tsd-comment tsd-typography">
  69. </div>
  70. </section>
  71. <section class="tsd-panel tsd-hierarchy">
  72. <h3>Hierarchy</h3>
  73. <ul class="tsd-hierarchy">
  74. <li>
  75. <span class="tsd-signature-type">EventEmitter</span>
  76. <ul class="tsd-hierarchy">
  77. <li>
  78. <span class="target">Stream</span>
  79. <ul class="tsd-hierarchy">
  80. <li>
  81. <a href="localstream.html" class="tsd-signature-type">LocalStream</a>
  82. </li>
  83. <li>
  84. <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a>
  85. </li>
  86. </ul>
  87. </li>
  88. </ul>
  89. </li>
  90. </ul>
  91. </section>
  92. <section class="tsd-panel-group tsd-index-group">
  93. <h2>Index</h2>
  94. <section class="tsd-panel tsd-index-panel">
  95. <div class="tsd-index-content">
  96. <section class="tsd-index-section tsd-is-external">
  97. <h3>Properties</h3>
  98. <ul class="tsd-index-list">
  99. <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#audiomuted" class="tsd-kind-icon">audio<wbr>Muted</a></li>
  100. <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#id" class="tsd-kind-icon">id</a></li>
  101. <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#mediastream" class="tsd-kind-icon">media<wbr>Stream</a></li>
  102. <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#videomuted" class="tsd-kind-icon">video<wbr>Muted</a></li>
  103. </ul>
  104. </section>
  105. <section class="tsd-index-section tsd-is-external">
  106. <h3>Methods</h3>
  107. <ul class="tsd-index-list">
  108. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#destroy" class="tsd-kind-icon">destroy</a></li>
  109. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#getaudiolevel" class="tsd-kind-icon">get<wbr>Audio<wbr>Level</a></li>
  110. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#getmediatype" class="tsd-kind-icon">get<wbr>Media<wbr>Type</a></li>
  111. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#getstats" class="tsd-kind-icon">get<wbr>Stats</a></li>
  112. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#hasaudio" class="tsd-kind-icon">has<wbr>Audio</a></li>
  113. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#hasvideo" class="tsd-kind-icon">has<wbr>Video</a></li>
  114. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#muteaudio" class="tsd-kind-icon">mute<wbr>Audio</a></li>
  115. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#mutevideo" class="tsd-kind-icon">mute<wbr>Video</a></li>
  116. <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="stream.html#off" class="tsd-kind-icon">off</a></li>
  117. <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external"><a href="stream.html#on" class="tsd-kind-icon">on</a></li>
  118. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#play" class="tsd-kind-icon">play</a></li>
  119. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#resume" class="tsd-kind-icon">resume</a></li>
  120. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#stop" class="tsd-kind-icon">stop</a></li>
  121. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#unmuteaudio" class="tsd-kind-icon">unmute<wbr>Audio</a></li>
  122. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#unmutevideo" class="tsd-kind-icon">unmute<wbr>Video</a></li>
  123. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-static tsd-is-external"><a href="stream.html#use" class="tsd-kind-icon">use</a></li>
  124. </ul>
  125. </section>
  126. </div>
  127. </section>
  128. </section>
  129. <section class="tsd-panel-group tsd-member-group tsd-is-external">
  130. <h2>Properties</h2>
  131. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  132. <a name="audiomuted" class="tsd-anchor"></a>
  133. <h3>audio<wbr>Muted</h3>
  134. <div class="tsd-signature tsd-kind-icon">audio<wbr>Muted<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> = false</span></div>
  135. <aside class="tsd-sources">
  136. </aside>
  137. <div class="tsd-comment tsd-typography">
  138. <div class="lead">
  139. <p>当前流是否 mute 了音频</p>
  140. </div>
  141. </div>
  142. </section>
  143. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  144. <a name="id" class="tsd-anchor"></a>
  145. <h3>id</h3>
  146. <div class="tsd-signature tsd-kind-icon">id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
  147. <aside class="tsd-sources">
  148. </aside>
  149. <div class="tsd-comment tsd-typography">
  150. <div class="lead">
  151. <p>当前流ID</p>
  152. </div>
  153. </div>
  154. </section>
  155. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  156. <a name="mediastream" class="tsd-anchor"></a>
  157. <h3><span class="tsd-flag ts-flagReadonly">Readonly</span> media<wbr>Stream</h3>
  158. <div class="tsd-signature tsd-kind-icon">media<wbr>Stream<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">MediaStream</span></div>
  159. <aside class="tsd-sources">
  160. </aside>
  161. <div class="tsd-comment tsd-typography">
  162. <div class="lead">
  163. <p>当前流包含的媒体流,关于媒体流,请详见 <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream">MediaStream</a>。</p>
  164. </div>
  165. </div>
  166. </section>
  167. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  168. <a name="videomuted" class="tsd-anchor"></a>
  169. <h3>video<wbr>Muted</h3>
  170. <div class="tsd-signature tsd-kind-icon">video<wbr>Muted<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> = false</span></div>
  171. <aside class="tsd-sources">
  172. </aside>
  173. <div class="tsd-comment tsd-typography">
  174. <div class="lead">
  175. <p>当前流是否 mute 了视频</p>
  176. </div>
  177. </div>
  178. </section>
  179. </section>
  180. <section class="tsd-panel-group tsd-member-group tsd-is-external">
  181. <h2>Methods</h2>
  182. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  183. <a name="destroy" class="tsd-anchor"></a>
  184. <h3>destroy</h3>
  185. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  186. <li class="tsd-signature tsd-kind-icon">destroy<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  187. </ul>
  188. <ul class="tsd-descriptions">
  189. <li class="tsd-description">
  190. <aside class="tsd-sources">
  191. </aside>
  192. <div class="tsd-comment tsd-typography">
  193. <div class="lead">
  194. <p>销毁当前流,一般在本地流不再被使用时,可调用此方法销毁,解除摄像头或麦克风设备的占用。</p>
  195. <blockquote>
  196. <p>注:远端流,不需要手动调用此方法</p>
  197. </blockquote>
  198. </div>
  199. <dl class="tsd-comment-tags">
  200. <dt>example</dt>
  201. <dd><pre><code class="language-js">stream.destroy();</code></pre>
  202. </dd>
  203. </dl>
  204. </div>
  205. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  206. </li>
  207. </ul>
  208. </section>
  209. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  210. <a name="getaudiolevel" class="tsd-anchor"></a>
  211. <h3>get<wbr>Audio<wbr>Level</h3>
  212. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  213. <li class="tsd-signature tsd-kind-icon">get<wbr>Audio<wbr>Level<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
  214. </ul>
  215. <ul class="tsd-descriptions">
  216. <li class="tsd-description">
  217. <aside class="tsd-sources">
  218. </aside>
  219. <div class="tsd-comment tsd-typography">
  220. <div class="lead">
  221. <p>获取当前流的音量大小,只有当本地流或远端流中有音频数据才有效。</p>
  222. </div>
  223. <dl class="tsd-comment-tags">
  224. <dt>example</dt>
  225. <dd><pre><code class="language-js"><span class="hljs-built_in">setInterval</span>(<span class="hljs-function">() =&gt;</span> {
  226. <span class="hljs-keyword">const</span> level = stream.getAudioLevel();
  227. <span class="hljs-keyword">if</span> (level &gt; <span class="hljs-number">0</span>) {
  228. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`user <span class="hljs-subst">${stream.userId}</span> is speaking`</span>);
  229. }
  230. }, <span class="hljs-number">200</span>);</code></pre>
  231. </dd>
  232. </dl>
  233. </div>
  234. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
  235. </li>
  236. </ul>
  237. </section>
  238. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  239. <a name="getmediatype" class="tsd-anchor"></a>
  240. <h3>get<wbr>Media<wbr>Type</h3>
  241. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  242. <li class="tsd-signature tsd-kind-icon">get<wbr>Media<wbr>Type<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../index.html#mediatype" class="tsd-signature-type">MediaType</a></li>
  243. </ul>
  244. <ul class="tsd-descriptions">
  245. <li class="tsd-description">
  246. <aside class="tsd-sources">
  247. </aside>
  248. <div class="tsd-comment tsd-typography">
  249. <div class="lead">
  250. <p>获取流的媒体类型</p>
  251. </div>
  252. <dl class="tsd-comment-tags">
  253. <dt>example</dt>
  254. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> type = stream.getMediaType();</code></pre>
  255. </dd>
  256. </dl>
  257. </div>
  258. <h4 class="tsd-returns-title">Returns <a href="../index.html#mediatype" class="tsd-signature-type">MediaType</a></h4>
  259. </li>
  260. </ul>
  261. </section>
  262. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  263. <a name="getstats" class="tsd-anchor"></a>
  264. <h3>get<wbr>Stats</h3>
  265. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  266. <li class="tsd-signature tsd-kind-icon">get<wbr>Stats<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/streamstats.html" class="tsd-signature-type">StreamStats</a><span class="tsd-signature-symbol">&gt;</span></li>
  267. </ul>
  268. <ul class="tsd-descriptions">
  269. <li class="tsd-description">
  270. <aside class="tsd-sources">
  271. </aside>
  272. <div class="tsd-comment tsd-typography">
  273. <div class="lead">
  274. <p>获取流发布或订阅后的统计数据</p>
  275. </div>
  276. <dl class="tsd-comment-tags">
  277. <dt>example</dt>
  278. <dd><pre><code class="language-js">stream
  279. .getStats()
  280. .then(<span class="hljs-function">(<span class="hljs-params">stats</span>) =&gt;</span> {
  281. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;当前流的统计数据为: &#x27;</span>, stats);
  282. });</code></pre>
  283. </dd>
  284. </dl>
  285. </div>
  286. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/streamstats.html" class="tsd-signature-type">StreamStats</a><span class="tsd-signature-symbol">&gt;</span></h4>
  287. </li>
  288. </ul>
  289. </section>
  290. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  291. <a name="hasaudio" class="tsd-anchor"></a>
  292. <h3>has<wbr>Audio</h3>
  293. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  294. <li class="tsd-signature tsd-kind-icon">has<wbr>Audio<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  295. </ul>
  296. <ul class="tsd-descriptions">
  297. <li class="tsd-description">
  298. <aside class="tsd-sources">
  299. </aside>
  300. <div class="tsd-comment tsd-typography">
  301. <div class="lead">
  302. <p>判断当前流是否有音频</p>
  303. </div>
  304. <dl class="tsd-comment-tags">
  305. <dt>example</dt>
  306. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.hasAudio();</code></pre>
  307. </dd>
  308. </dl>
  309. </div>
  310. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  311. </li>
  312. </ul>
  313. </section>
  314. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  315. <a name="hasvideo" class="tsd-anchor"></a>
  316. <h3>has<wbr>Video</h3>
  317. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  318. <li class="tsd-signature tsd-kind-icon">has<wbr>Video<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  319. </ul>
  320. <ul class="tsd-descriptions">
  321. <li class="tsd-description">
  322. <aside class="tsd-sources">
  323. </aside>
  324. <div class="tsd-comment tsd-typography">
  325. <div class="lead">
  326. <p>判断当前流是否有视频</p>
  327. </div>
  328. <dl class="tsd-comment-tags">
  329. <dt>example</dt>
  330. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.hasVideo();</code></pre>
  331. </dd>
  332. </dl>
  333. </div>
  334. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  335. </li>
  336. </ul>
  337. </section>
  338. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  339. <a name="muteaudio" class="tsd-anchor"></a>
  340. <h3>mute<wbr>Audio</h3>
  341. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  342. <li class="tsd-signature tsd-kind-icon">mute<wbr>Audio<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  343. </ul>
  344. <ul class="tsd-descriptions">
  345. <li class="tsd-description">
  346. <aside class="tsd-sources">
  347. </aside>
  348. <div class="tsd-comment tsd-typography">
  349. <div class="lead">
  350. <p>mute 当前流的音频</p>
  351. <ul>
  352. <li>本地流调用此方法时,远端用户将收到 <code>mute-audio</code> 的事件通知,流的 audioMuted 状态也将改变</li>
  353. <li>远端流调用此方法时,仅为不从服务器拉取音频数据,并无事件通知用户,且不改变流的 audioMuted 状态</li>
  354. </ul>
  355. </div>
  356. <dl class="tsd-comment-tags">
  357. <dt>example</dt>
  358. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.muteAudio();</code></pre>
  359. </dd>
  360. </dl>
  361. </div>
  362. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  363. </li>
  364. </ul>
  365. </section>
  366. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  367. <a name="mutevideo" class="tsd-anchor"></a>
  368. <h3>mute<wbr>Video</h3>
  369. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  370. <li class="tsd-signature tsd-kind-icon">mute<wbr>Video<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  371. </ul>
  372. <ul class="tsd-descriptions">
  373. <li class="tsd-description">
  374. <aside class="tsd-sources">
  375. </aside>
  376. <div class="tsd-comment tsd-typography">
  377. <div class="lead">
  378. <p>mute 当前流的视频</p>
  379. <ul>
  380. <li>本地流调用此方法时,远端用户将收到 <code>mute-video</code> 的事件通知,流的 videoMuted 状态也将改变</li>
  381. <li>远端流调用此方法时,仅为不从服务器拉取视频数据,并无事件通知用户,且不改变流的 videoMuted 状态</li>
  382. </ul>
  383. </div>
  384. <dl class="tsd-comment-tags">
  385. <dt>example</dt>
  386. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.muteVideo();</code></pre>
  387. </dd>
  388. </dl>
  389. </div>
  390. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  391. </li>
  392. </ul>
  393. </section>
  394. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  395. <a name="off" class="tsd-anchor"></a>
  396. <h3>off</h3>
  397. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  398. <li class="tsd-signature tsd-kind-icon">off&lt;T&gt;<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, listener<span class="tsd-signature-symbol">: </span><a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">EventEmitter</span></li>
  399. </ul>
  400. <ul class="tsd-descriptions">
  401. <li class="tsd-description">
  402. <aside class="tsd-sources">
  403. <p>Inherited from EventEmitter.off</p>
  404. </aside>
  405. <div class="tsd-comment tsd-typography">
  406. <div class="lead">
  407. <p>取消监听流对象事件</p>
  408. </div>
  409. </div>
  410. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  411. <ul class="tsd-type-parameters">
  412. <li>
  413. <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"*"</span></h4>
  414. </li>
  415. </ul>
  416. <h4 class="tsd-parameters-title">Parameters</h4>
  417. <ul class="tsd-parameters">
  418. <li>
  419. <h5>type: <span class="tsd-signature-type">T</span></h5>
  420. <div class="tsd-comment tsd-typography">
  421. <p>流对象事件类型,特别的,当为 &#39;*&#39; 时,取消监听所有事件</p>
  422. </div>
  423. </li>
  424. <li>
  425. <h5>listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
  426. <div class="tsd-comment tsd-typography">
  427. <p>流对象事件监听函数</p>
  428. </div>
  429. </li>
  430. </ul>
  431. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
  432. </li>
  433. </ul>
  434. </section>
  435. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  436. <a name="on" class="tsd-anchor"></a>
  437. <h3>on</h3>
  438. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  439. <li class="tsd-signature tsd-kind-icon">on&lt;T&gt;<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, listener<span class="tsd-signature-symbol">: </span><a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">EventEmitter</span></li>
  440. </ul>
  441. <ul class="tsd-descriptions">
  442. <li class="tsd-description">
  443. <aside class="tsd-sources">
  444. <p>Inherited from EventEmitter.on</p>
  445. </aside>
  446. <div class="tsd-comment tsd-typography">
  447. <div class="lead">
  448. <p>监听流对象事件</p>
  449. </div>
  450. </div>
  451. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  452. <ul class="tsd-type-parameters">
  453. <li>
  454. <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a></h4>
  455. </li>
  456. </ul>
  457. <h4 class="tsd-parameters-title">Parameters</h4>
  458. <ul class="tsd-parameters">
  459. <li>
  460. <h5>type: <span class="tsd-signature-type">T</span></h5>
  461. <div class="tsd-comment tsd-typography">
  462. <p>流事件类型</p>
  463. </div>
  464. </li>
  465. <li>
  466. <h5>listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
  467. <div class="tsd-comment tsd-typography">
  468. <p>流事件监听函数</p>
  469. </div>
  470. </li>
  471. </ul>
  472. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
  473. </li>
  474. </ul>
  475. </section>
  476. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  477. <a name="play" class="tsd-anchor"></a>
  478. <h3>play</h3>
  479. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  480. <li class="tsd-signature tsd-kind-icon">play<span class="tsd-signature-symbol">(</span>container<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">HTMLElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span>, opts<span class="tsd-signature-symbol">?: </span><a href="../interfaces/playoptions.html" class="tsd-signature-type">PlayOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  481. </ul>
  482. <ul class="tsd-descriptions">
  483. <li class="tsd-description">
  484. <aside class="tsd-sources">
  485. </aside>
  486. <div class="tsd-comment tsd-typography">
  487. <div class="lead">
  488. <p>播放当前流</p>
  489. </div>
  490. <dl class="tsd-comment-tags">
  491. <dt>example</dt>
  492. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> container = <span class="hljs-string">&#x27;xxx&#x27;</span>; <span class="hljs-comment">// 比如 id 为 xxx 的 div 元素</span>
  493. stream
  494. .play(container)
  495. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  496. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`播放失败: <span class="hljs-subst">${err}</span>`</span>); <span class="hljs-comment">// 一般由于浏览器对自动播放的限制导致播放失败</span>
  497. });</code></pre>
  498. </dd>
  499. <dt>reject</dt>
  500. <dd><p><a href="rtcerror.html">RtcError</a></p>
  501. </dd>
  502. </dl>
  503. </div>
  504. <h4 class="tsd-parameters-title">Parameters</h4>
  505. <ul class="tsd-parameters">
  506. <li>
  507. <h5>container: <span class="tsd-signature-type">HTMLElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></h5>
  508. <div class="tsd-comment tsd-typography">
  509. <p>播放音视频时,包裹 video 标签所用的容器元素或容器元素的 ID</p>
  510. </div>
  511. </li>
  512. <li>
  513. <h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <a href="../interfaces/playoptions.html" class="tsd-signature-type">PlayOptions</a></h5>
  514. <div class="tsd-comment tsd-typography">
  515. <p>其他播放参数,参见<a href="../interfaces/playoptions.html">PlayOptions</a></p>
  516. </div>
  517. </li>
  518. </ul>
  519. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  520. </li>
  521. </ul>
  522. </section>
  523. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  524. <a name="resume" class="tsd-anchor"></a>
  525. <h3>resume</h3>
  526. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  527. <li class="tsd-signature tsd-kind-icon">resume<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  528. </ul>
  529. <ul class="tsd-descriptions">
  530. <li class="tsd-description">
  531. <aside class="tsd-sources">
  532. </aside>
  533. <div class="tsd-comment tsd-typography">
  534. <div class="lead">
  535. <p>恢复播放流,一般由于浏览器限制无法自动播放时,可提示用户手动触发该方法进行恢复播放</p>
  536. </div>
  537. <dl class="tsd-comment-tags">
  538. <dt>example</dt>
  539. <dd><pre><code class="language-js">stream
  540. .resume()
  541. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  542. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`恢复播放失败:<span class="hljs-subst">${err}</span>`</span>);
  543. });</code></pre>
  544. </dd>
  545. </dl>
  546. </div>
  547. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  548. </li>
  549. </ul>
  550. </section>
  551. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  552. <a name="stop" class="tsd-anchor"></a>
  553. <h3>stop</h3>
  554. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  555. <li class="tsd-signature tsd-kind-icon">stop<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  556. </ul>
  557. <ul class="tsd-descriptions">
  558. <li class="tsd-description">
  559. <aside class="tsd-sources">
  560. </aside>
  561. <div class="tsd-comment tsd-typography">
  562. <div class="lead">
  563. <p>停止播放当前流</p>
  564. </div>
  565. <dl class="tsd-comment-tags">
  566. <dt>example</dt>
  567. <dd><pre><code class="language-js">stream.stop();</code></pre>
  568. </dd>
  569. </dl>
  570. </div>
  571. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  572. </li>
  573. </ul>
  574. </section>
  575. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  576. <a name="unmuteaudio" class="tsd-anchor"></a>
  577. <h3>unmute<wbr>Audio</h3>
  578. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  579. <li class="tsd-signature tsd-kind-icon">unmute<wbr>Audio<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  580. </ul>
  581. <ul class="tsd-descriptions">
  582. <li class="tsd-description">
  583. <aside class="tsd-sources">
  584. </aside>
  585. <div class="tsd-comment tsd-typography">
  586. <div class="lead">
  587. <p>unmute 当前流的音频</p>
  588. <ul>
  589. <li>本地流调用此方法时,远端用户将收到 <code>unmute-audio</code> 的事件通知,流的 audioMuted 状态也将改变</li>
  590. <li>远端流调用此方法时,会从服务器拉取音频数据,并无事件通知用户,且不改变流的 audioMuted 状态</li>
  591. </ul>
  592. </div>
  593. <dl class="tsd-comment-tags">
  594. <dt>example</dt>
  595. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteAudio();</code></pre>
  596. </dd>
  597. </dl>
  598. </div>
  599. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  600. </li>
  601. </ul>
  602. </section>
  603. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  604. <a name="unmutevideo" class="tsd-anchor"></a>
  605. <h3>unmute<wbr>Video</h3>
  606. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  607. <li class="tsd-signature tsd-kind-icon">unmute<wbr>Video<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
  608. </ul>
  609. <ul class="tsd-descriptions">
  610. <li class="tsd-description">
  611. <aside class="tsd-sources">
  612. </aside>
  613. <div class="tsd-comment tsd-typography">
  614. <div class="lead">
  615. <p>unmute 当前流的视频</p>
  616. <ul>
  617. <li>本地流调用此方法时,远端用户将收到 <code>unmute-video</code> 的事件通知,流的 videoMuted 状态也将改变</li>
  618. <li>远端流调用此方法时,会从服务器拉取视频数据,并无事件通知用户,且不改变流的 videoMuted 状态</li>
  619. </ul>
  620. </div>
  621. <dl class="tsd-comment-tags">
  622. <dt>example</dt>
  623. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteVideo();</code></pre>
  624. </dd>
  625. </dl>
  626. </div>
  627. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  628. </li>
  629. </ul>
  630. </section>
  631. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static tsd-is-external">
  632. <a name="use" class="tsd-anchor"></a>
  633. <h3><span class="tsd-flag ts-flagStatic">Static</span> use</h3>
  634. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static tsd-is-external">
  635. <li class="tsd-signature tsd-kind-icon">use<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">...</span>plugins<span class="tsd-signature-symbol">: </span><a href="../interfaces/streamplugin.html" class="tsd-signature-type">StreamPlugin</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  636. </ul>
  637. <ul class="tsd-descriptions">
  638. <li class="tsd-description">
  639. <aside class="tsd-sources">
  640. </aside>
  641. <div class="tsd-comment tsd-typography">
  642. <div class="lead">
  643. <p>加载某个插件,使用插件功能</p>
  644. </div>
  645. </div>
  646. <h4 class="tsd-parameters-title">Parameters</h4>
  647. <ul class="tsd-parameters">
  648. <li>
  649. <h5><span class="tsd-flag ts-flagRest">Rest</span> <span class="tsd-signature-symbol">...</span>plugins: <a href="../interfaces/streamplugin.html" class="tsd-signature-type">StreamPlugin</a><span class="tsd-signature-symbol">[]</span></h5>
  650. <div class="tsd-comment tsd-typography">
  651. <p>插件</p>
  652. </div>
  653. </li>
  654. </ul>
  655. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  656. </li>
  657. </ul>
  658. </section>
  659. </section>
  660. </div>
  661. <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
  662. <nav class="tsd-navigation primary">
  663. <ul>
  664. <li class="globals ">
  665. <a href="../index.html"><em>Globals</em></a>
  666. </li>
  667. </ul>
  668. </nav>
  669. <nav class="tsd-navigation secondary menu-sticky">
  670. <ul class="before-current">
  671. </ul>
  672. <ul class="current">
  673. <li class="current tsd-kind-class tsd-is-external">
  674. <a href="stream.html" class="tsd-kind-icon">Stream</a>
  675. <ul>
  676. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  677. <a href="stream.html#audiomuted" class="tsd-kind-icon">audio<wbr>Muted</a>
  678. </li>
  679. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  680. <a href="stream.html#id" class="tsd-kind-icon">id</a>
  681. </li>
  682. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  683. <a href="stream.html#mediastream" class="tsd-kind-icon">media<wbr>Stream</a>
  684. </li>
  685. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  686. <a href="stream.html#videomuted" class="tsd-kind-icon">video<wbr>Muted</a>
  687. </li>
  688. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  689. <a href="stream.html#destroy" class="tsd-kind-icon">destroy</a>
  690. </li>
  691. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  692. <a href="stream.html#getaudiolevel" class="tsd-kind-icon">get<wbr>Audio<wbr>Level</a>
  693. </li>
  694. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  695. <a href="stream.html#getmediatype" class="tsd-kind-icon">get<wbr>Media<wbr>Type</a>
  696. </li>
  697. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  698. <a href="stream.html#getstats" class="tsd-kind-icon">get<wbr>Stats</a>
  699. </li>
  700. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  701. <a href="stream.html#hasaudio" class="tsd-kind-icon">has<wbr>Audio</a>
  702. </li>
  703. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  704. <a href="stream.html#hasvideo" class="tsd-kind-icon">has<wbr>Video</a>
  705. </li>
  706. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  707. <a href="stream.html#muteaudio" class="tsd-kind-icon">mute<wbr>Audio</a>
  708. </li>
  709. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  710. <a href="stream.html#mutevideo" class="tsd-kind-icon">mute<wbr>Video</a>
  711. </li>
  712. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  713. <a href="stream.html#off" class="tsd-kind-icon">off</a>
  714. </li>
  715. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  716. <a href="stream.html#on" class="tsd-kind-icon">on</a>
  717. </li>
  718. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  719. <a href="stream.html#play" class="tsd-kind-icon">play</a>
  720. </li>
  721. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  722. <a href="stream.html#resume" class="tsd-kind-icon">resume</a>
  723. </li>
  724. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  725. <a href="stream.html#stop" class="tsd-kind-icon">stop</a>
  726. </li>
  727. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  728. <a href="stream.html#unmuteaudio" class="tsd-kind-icon">unmute<wbr>Audio</a>
  729. </li>
  730. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  731. <a href="stream.html#unmutevideo" class="tsd-kind-icon">unmute<wbr>Video</a>
  732. </li>
  733. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static tsd-is-external">
  734. <a href="stream.html#use" class="tsd-kind-icon">use</a>
  735. </li>
  736. </ul>
  737. </li>
  738. </ul>
  739. <ul class="after-current">
  740. </ul>
  741. </nav>
  742. </div>
  743. </div>
  744. </div>
  745. <footer class="with-border-bottom">
  746. <div class="container">
  747. <h2>Legend</h2>
  748. <div class="tsd-legend-group">
  749. </div>
  750. </div>
  751. </footer>
  752. <div class="container tsd-generator">
  753. <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
  754. </div>
  755. <div class="overlay"></div>
  756. <script src="../assets/js/main.js"></script>
  757. </body>
  758. </html>