stream.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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 class="lead">
  70. <p>LocalStream 和 RemoteStream 的基类</p>
  71. </div>
  72. </div>
  73. </section>
  74. <section class="tsd-panel tsd-hierarchy">
  75. <h3>Hierarchy</h3>
  76. <ul class="tsd-hierarchy">
  77. <li>
  78. <span class="tsd-signature-type">EventEmitter</span>
  79. <ul class="tsd-hierarchy">
  80. <li>
  81. <span class="target">Stream</span>
  82. <ul class="tsd-hierarchy">
  83. <li>
  84. <a href="localstream.html" class="tsd-signature-type">LocalStream</a>
  85. </li>
  86. <li>
  87. <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a>
  88. </li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </li>
  93. </ul>
  94. </section>
  95. <section class="tsd-panel-group tsd-index-group">
  96. <h2>Index</h2>
  97. <section class="tsd-panel tsd-index-panel">
  98. <div class="tsd-index-content">
  99. <section class="tsd-index-section tsd-is-external">
  100. <h3>Properties</h3>
  101. <ul class="tsd-index-list">
  102. <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>
  103. <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#id" class="tsd-kind-icon">id</a></li>
  104. <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>
  105. <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>
  106. </ul>
  107. </section>
  108. <section class="tsd-index-section tsd-is-external">
  109. <h3>Methods</h3>
  110. <ul class="tsd-index-list">
  111. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#destroy" class="tsd-kind-icon">destroy</a></li>
  112. <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>
  113. <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>
  114. <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>
  115. <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>
  116. <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>
  117. <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>
  118. <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>
  119. <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>
  120. <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>
  121. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#play" class="tsd-kind-icon">play</a></li>
  122. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#resume" class="tsd-kind-icon">resume</a></li>
  123. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#stop" class="tsd-kind-icon">stop</a></li>
  124. <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>
  125. <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>
  126. </ul>
  127. </section>
  128. </div>
  129. </section>
  130. </section>
  131. <section class="tsd-panel-group tsd-member-group tsd-is-external">
  132. <h2>Properties</h2>
  133. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  134. <a name="audiomuted" class="tsd-anchor"></a>
  135. <h3>audio<wbr>Muted</h3>
  136. <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>
  137. <aside class="tsd-sources">
  138. </aside>
  139. <div class="tsd-comment tsd-typography">
  140. <div class="lead">
  141. <p>当前流是否 mute 了音频</p>
  142. </div>
  143. </div>
  144. </section>
  145. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  146. <a name="id" class="tsd-anchor"></a>
  147. <h3>id</h3>
  148. <div class="tsd-signature tsd-kind-icon">id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
  149. <aside class="tsd-sources">
  150. </aside>
  151. <div class="tsd-comment tsd-typography">
  152. <div class="lead">
  153. <p>当前流ID</p>
  154. </div>
  155. </div>
  156. </section>
  157. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  158. <a name="mediastream" class="tsd-anchor"></a>
  159. <h3><span class="tsd-flag ts-flagReadonly">Readonly</span> media<wbr>Stream</h3>
  160. <div class="tsd-signature tsd-kind-icon">media<wbr>Stream<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">MediaStream</span></div>
  161. <aside class="tsd-sources">
  162. </aside>
  163. <div class="tsd-comment tsd-typography">
  164. <div class="lead">
  165. <p>当前流包含的媒体流,关于媒体流,请详见 <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream">MediaStream</a>。</p>
  166. </div>
  167. </div>
  168. </section>
  169. <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
  170. <a name="videomuted" class="tsd-anchor"></a>
  171. <h3>video<wbr>Muted</h3>
  172. <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>
  173. <aside class="tsd-sources">
  174. </aside>
  175. <div class="tsd-comment tsd-typography">
  176. <div class="lead">
  177. <p>当前流是否 mute 了视频</p>
  178. </div>
  179. </div>
  180. </section>
  181. </section>
  182. <section class="tsd-panel-group tsd-member-group tsd-is-external">
  183. <h2>Methods</h2>
  184. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  185. <a name="destroy" class="tsd-anchor"></a>
  186. <h3>destroy</h3>
  187. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  188. <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>
  189. </ul>
  190. <ul class="tsd-descriptions">
  191. <li class="tsd-description">
  192. <aside class="tsd-sources">
  193. </aside>
  194. <div class="tsd-comment tsd-typography">
  195. <div class="lead">
  196. <p>销毁当前流,一般在本地流不再被使用时,可调用此方法销毁,解除摄像头或麦克风设备的占用。
  197. 注:远端流,不需要手动调用此方法</p>
  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> 的事件通知</li>
  353. <li>远端流调用此方法时,仅为不从服务器拉取音频数据,并无事件通知远端用户</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();
  359. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream&#x27;audio is muted <span class="hljs-subst">${stream.audioMuted}</span>`</span>);</code></pre>
  360. </dd>
  361. </dl>
  362. </div>
  363. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  364. <p>操作是否成功</p>
  365. </li>
  366. </ul>
  367. </section>
  368. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  369. <a name="mutevideo" class="tsd-anchor"></a>
  370. <h3>mute<wbr>Video</h3>
  371. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  372. <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>
  373. </ul>
  374. <ul class="tsd-descriptions">
  375. <li class="tsd-description">
  376. <aside class="tsd-sources">
  377. </aside>
  378. <div class="tsd-comment tsd-typography">
  379. <div class="lead">
  380. <p>mute 当前流的视频</p>
  381. <ul>
  382. <li>本地流调用此方法时,将不向服务器推送视频数据,远端用户将收到 <code>mute-video</code> 的事件通知</li>
  383. <li>远端流调用此方法时,仅为不从服务器拉取视频数据,并无事件通知远端用户</li>
  384. </ul>
  385. </div>
  386. <dl class="tsd-comment-tags">
  387. <dt>example</dt>
  388. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.muteVideo();
  389. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream&#x27;s video is muted <span class="hljs-subst">${stream.videoMuted}</span>`</span>);</code></pre>
  390. </dd>
  391. </dl>
  392. </div>
  393. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  394. <p>操作是否成功</p>
  395. </li>
  396. </ul>
  397. </section>
  398. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  399. <a name="off" class="tsd-anchor"></a>
  400. <h3>off</h3>
  401. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  402. <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>
  403. </ul>
  404. <ul class="tsd-descriptions">
  405. <li class="tsd-description">
  406. <aside class="tsd-sources">
  407. <p>Inherited from EventEmitter.off</p>
  408. </aside>
  409. <div class="tsd-comment tsd-typography">
  410. <div class="lead">
  411. <p>取消监听流对象事件</p>
  412. </div>
  413. </div>
  414. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  415. <ul class="tsd-type-parameters">
  416. <li>
  417. <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>
  418. </li>
  419. </ul>
  420. <h4 class="tsd-parameters-title">Parameters</h4>
  421. <ul class="tsd-parameters">
  422. <li>
  423. <h5>type: <span class="tsd-signature-type">T</span></h5>
  424. <div class="tsd-comment tsd-typography">
  425. <p>流对象事件类型,特别的,当为 &#39;*&#39; 时,取消监听所有事件</p>
  426. </div>
  427. </li>
  428. <li>
  429. <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>
  430. <div class="tsd-comment tsd-typography">
  431. <p>流对象事件监听函数</p>
  432. </div>
  433. </li>
  434. </ul>
  435. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
  436. </li>
  437. </ul>
  438. </section>
  439. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  440. <a name="on" class="tsd-anchor"></a>
  441. <h3>on</h3>
  442. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  443. <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>
  444. </ul>
  445. <ul class="tsd-descriptions">
  446. <li class="tsd-description">
  447. <aside class="tsd-sources">
  448. <p>Inherited from EventEmitter.on</p>
  449. </aside>
  450. <div class="tsd-comment tsd-typography">
  451. <div class="lead">
  452. <p>监听流对象事件</p>
  453. </div>
  454. </div>
  455. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  456. <ul class="tsd-type-parameters">
  457. <li>
  458. <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a></h4>
  459. </li>
  460. </ul>
  461. <h4 class="tsd-parameters-title">Parameters</h4>
  462. <ul class="tsd-parameters">
  463. <li>
  464. <h5>type: <span class="tsd-signature-type">T</span></h5>
  465. <div class="tsd-comment tsd-typography">
  466. <p>流事件类型</p>
  467. </div>
  468. </li>
  469. <li>
  470. <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>
  471. <div class="tsd-comment tsd-typography">
  472. <p>流事件监听函数</p>
  473. </div>
  474. </li>
  475. </ul>
  476. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
  477. </li>
  478. </ul>
  479. </section>
  480. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  481. <a name="play" class="tsd-anchor"></a>
  482. <h3>play</h3>
  483. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  484. <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>
  485. </ul>
  486. <ul class="tsd-descriptions">
  487. <li class="tsd-description">
  488. <aside class="tsd-sources">
  489. </aside>
  490. <div class="tsd-comment tsd-typography">
  491. <div class="lead">
  492. <p>播放当前流</p>
  493. </div>
  494. <dl class="tsd-comment-tags">
  495. <dt>example</dt>
  496. <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>
  497. stream
  498. .play(container)
  499. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  500. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`播放失败: <span class="hljs-subst">${err}</span>`</span>); <span class="hljs-comment">// 一般由于浏览器对自动播放的限制导致播放失败</span>
  501. });</code></pre>
  502. </dd>
  503. <dt>reject</dt>
  504. <dd><p><a href="rtcerror.html">RtcError</a></p>
  505. </dd>
  506. </dl>
  507. </div>
  508. <h4 class="tsd-parameters-title">Parameters</h4>
  509. <ul class="tsd-parameters">
  510. <li>
  511. <h5>container: <span class="tsd-signature-type">HTMLElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></h5>
  512. <div class="tsd-comment tsd-typography">
  513. <p>播放音视频时,包裹 video 标签所用的容器元素或容器元素的 ID</p>
  514. </div>
  515. </li>
  516. <li>
  517. <h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <a href="../interfaces/playoptions.html" class="tsd-signature-type">PlayOptions</a></h5>
  518. <div class="tsd-comment tsd-typography">
  519. <p>其他播放参数,参见<a href="../interfaces/playoptions.html">PlayOptions</a></p>
  520. </div>
  521. </li>
  522. </ul>
  523. <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>
  524. </li>
  525. </ul>
  526. </section>
  527. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  528. <a name="resume" class="tsd-anchor"></a>
  529. <h3>resume</h3>
  530. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  531. <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>
  532. </ul>
  533. <ul class="tsd-descriptions">
  534. <li class="tsd-description">
  535. <aside class="tsd-sources">
  536. </aside>
  537. <div class="tsd-comment tsd-typography">
  538. <div class="lead">
  539. <p>恢复播放流,一般由于浏览器限制无法自动播放时,可提示用户手动触发该方法进行恢复播放</p>
  540. </div>
  541. <dl class="tsd-comment-tags">
  542. <dt>example</dt>
  543. <dd><pre><code class="language-js">stream
  544. .resume()
  545. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  546. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`恢复播放失败:<span class="hljs-subst">${err}</span>`</span>);
  547. });</code></pre>
  548. </dd>
  549. </dl>
  550. </div>
  551. <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>
  552. </li>
  553. </ul>
  554. </section>
  555. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  556. <a name="stop" class="tsd-anchor"></a>
  557. <h3>stop</h3>
  558. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  559. <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>
  560. </ul>
  561. <ul class="tsd-descriptions">
  562. <li class="tsd-description">
  563. <aside class="tsd-sources">
  564. </aside>
  565. <div class="tsd-comment tsd-typography">
  566. <div class="lead">
  567. <p>停止播放当前流</p>
  568. </div>
  569. <dl class="tsd-comment-tags">
  570. <dt>example</dt>
  571. <dd><pre><code class="language-js">stream.stop();</code></pre>
  572. </dd>
  573. </dl>
  574. </div>
  575. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  576. </li>
  577. </ul>
  578. </section>
  579. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  580. <a name="unmuteaudio" class="tsd-anchor"></a>
  581. <h3>unmute<wbr>Audio</h3>
  582. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  583. <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>
  584. </ul>
  585. <ul class="tsd-descriptions">
  586. <li class="tsd-description">
  587. <aside class="tsd-sources">
  588. </aside>
  589. <div class="tsd-comment tsd-typography">
  590. <div class="lead">
  591. <p>unmute 当前流的音频</p>
  592. <ul>
  593. <li>本地流调用此方法时,将向服务器推送音频数据,远端用户将收到 <code>unmute-audio</code> 的事件通知</li>
  594. <li>远端流调用此方法时,会从服务器拉取音频数据,并无事件通知远端用户</li>
  595. </ul>
  596. </div>
  597. <dl class="tsd-comment-tags">
  598. <dt>example</dt>
  599. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteAudio();
  600. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream&#x27;s audio is muted <span class="hljs-subst">${stream.audioMuted}</span>`</span>);</code></pre>
  601. </dd>
  602. </dl>
  603. </div>
  604. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  605. <p>操作是否成功</p>
  606. </li>
  607. </ul>
  608. </section>
  609. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  610. <a name="unmutevideo" class="tsd-anchor"></a>
  611. <h3>unmute<wbr>Video</h3>
  612. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  613. <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>
  614. </ul>
  615. <ul class="tsd-descriptions">
  616. <li class="tsd-description">
  617. <aside class="tsd-sources">
  618. </aside>
  619. <div class="tsd-comment tsd-typography">
  620. <div class="lead">
  621. <p>unmute 当前流的视频</p>
  622. <ul>
  623. <li>本地流调用此方法时,将向服务器推送视频数据,远端用户将收到 <code>unmute-video</code> 的事件通知</li>
  624. <li>远端流调用此方法时,会从服务器拉取视频数据,并无事件通知远端用户</li>
  625. </ul>
  626. </div>
  627. <dl class="tsd-comment-tags">
  628. <dt>example</dt>
  629. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteVideo();
  630. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream&#x27;s video is muted <span class="hljs-subst">${stream.videoMuted}</span>`</span>);</code></pre>
  631. </dd>
  632. </dl>
  633. </div>
  634. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
  635. <p>操作是否成功</p>
  636. </li>
  637. </ul>
  638. </section>
  639. </section>
  640. </div>
  641. <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
  642. <nav class="tsd-navigation primary">
  643. <ul>
  644. <li class="globals ">
  645. <a href="../index.html"><em>Globals</em></a>
  646. </li>
  647. </ul>
  648. </nav>
  649. <nav class="tsd-navigation secondary menu-sticky">
  650. <ul class="before-current">
  651. </ul>
  652. <ul class="current">
  653. <li class="current tsd-kind-class tsd-is-external">
  654. <a href="stream.html" class="tsd-kind-icon">Stream</a>
  655. <ul>
  656. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  657. <a href="stream.html#audiomuted" class="tsd-kind-icon">audio<wbr>Muted</a>
  658. </li>
  659. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  660. <a href="stream.html#id" class="tsd-kind-icon">id</a>
  661. </li>
  662. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  663. <a href="stream.html#mediastream" class="tsd-kind-icon">media<wbr>Stream</a>
  664. </li>
  665. <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
  666. <a href="stream.html#videomuted" class="tsd-kind-icon">video<wbr>Muted</a>
  667. </li>
  668. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  669. <a href="stream.html#destroy" class="tsd-kind-icon">destroy</a>
  670. </li>
  671. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  672. <a href="stream.html#getaudiolevel" class="tsd-kind-icon">get<wbr>Audio<wbr>Level</a>
  673. </li>
  674. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  675. <a href="stream.html#getmediatype" class="tsd-kind-icon">get<wbr>Media<wbr>Type</a>
  676. </li>
  677. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  678. <a href="stream.html#getstats" class="tsd-kind-icon">get<wbr>Stats</a>
  679. </li>
  680. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  681. <a href="stream.html#hasaudio" class="tsd-kind-icon">has<wbr>Audio</a>
  682. </li>
  683. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  684. <a href="stream.html#hasvideo" class="tsd-kind-icon">has<wbr>Video</a>
  685. </li>
  686. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  687. <a href="stream.html#muteaudio" class="tsd-kind-icon">mute<wbr>Audio</a>
  688. </li>
  689. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  690. <a href="stream.html#mutevideo" class="tsd-kind-icon">mute<wbr>Video</a>
  691. </li>
  692. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  693. <a href="stream.html#off" class="tsd-kind-icon">off</a>
  694. </li>
  695. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
  696. <a href="stream.html#on" class="tsd-kind-icon">on</a>
  697. </li>
  698. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  699. <a href="stream.html#play" class="tsd-kind-icon">play</a>
  700. </li>
  701. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  702. <a href="stream.html#resume" class="tsd-kind-icon">resume</a>
  703. </li>
  704. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  705. <a href="stream.html#stop" class="tsd-kind-icon">stop</a>
  706. </li>
  707. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  708. <a href="stream.html#unmuteaudio" class="tsd-kind-icon">unmute<wbr>Audio</a>
  709. </li>
  710. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  711. <a href="stream.html#unmutevideo" class="tsd-kind-icon">unmute<wbr>Video</a>
  712. </li>
  713. </ul>
  714. </li>
  715. </ul>
  716. <ul class="after-current">
  717. </ul>
  718. </nav>
  719. </div>
  720. </div>
  721. </div>
  722. <footer class="with-border-bottom">
  723. <div class="container">
  724. <h2>Legend</h2>
  725. <div class="tsd-legend-group">
  726. </div>
  727. </div>
  728. </footer>
  729. <div class="container tsd-generator">
  730. <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
  731. </div>
  732. <div class="overlay"></div>
  733. <script src="../assets/js/main.js"></script>
  734. </body>
  735. </html>