| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- <!doctype html>
- <html class="default no-js">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Stream | @urtc/sdk-web</title>
- <meta name="description" content="Documentation for @urtc/sdk-web">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="../assets/css/main.css">
- </head>
- <body>
- <header>
- <div class="tsd-page-toolbar">
- <div class="container">
- <div class="table-wrap">
- <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
- <div class="field">
- <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
- <input id="tsd-search-field" type="text" />
- </div>
- <ul class="results">
- <li class="state loading">Preparing search index...</li>
- <li class="state failure">The search index is not available</li>
- </ul>
- <a href="../index.html" class="title">@urtc/sdk-web</a>
- </div>
- <div class="table-cell" id="tsd-widgets">
- <div id="tsd-filter">
- <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
- <div class="tsd-filter-group">
- <div class="tsd-select" id="tsd-filter-visibility">
- <span class="tsd-select-label">All</span>
- <ul class="tsd-select-list">
- <li data-value="public">Public</li>
- <li data-value="protected">Public/Protected</li>
- <li data-value="private" class="selected">All</li>
- </ul>
- </div>
- <input type="checkbox" id="tsd-filter-inherited" checked />
- <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
- <input type="checkbox" id="tsd-filter-externals" checked />
- <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
- </div>
- </div>
- <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
- </div>
- </div>
- </div>
- </div>
- <div class="tsd-page-title">
- <div class="container">
- <ul class="tsd-breadcrumb">
- <li>
- <a href="../index.html">Globals</a>
- </li>
- <li>
- <a href="stream.html">Stream</a>
- </li>
- </ul>
- <h1>Class Stream</h1>
- </div>
- </div>
- </header>
- <div class="container container-main">
- <div class="row">
- <div class="col-8 col-content">
- <section class="tsd-panel tsd-comment">
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>LocalStream 和 RemoteStream 的基类</p>
- </div>
- </div>
- </section>
- <section class="tsd-panel tsd-hierarchy">
- <h3>Hierarchy</h3>
- <ul class="tsd-hierarchy">
- <li>
- <span class="tsd-signature-type">EventEmitter</span>
- <ul class="tsd-hierarchy">
- <li>
- <span class="target">Stream</span>
- <ul class="tsd-hierarchy">
- <li>
- <a href="localstream.html" class="tsd-signature-type">LocalStream</a>
- </li>
- <li>
- <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a>
- </li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </section>
- <section class="tsd-panel-group tsd-index-group">
- <h2>Index</h2>
- <section class="tsd-panel tsd-index-panel">
- <div class="tsd-index-content">
- <section class="tsd-index-section tsd-is-external">
- <h3>Properties</h3>
- <ul class="tsd-index-list">
- <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>
- <li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="stream.html#id" class="tsd-kind-icon">id</a></li>
- <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>
- <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>
- </ul>
- </section>
- <section class="tsd-index-section tsd-is-external">
- <h3>Methods</h3>
- <ul class="tsd-index-list">
- <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#destroy" class="tsd-kind-icon">destroy</a></li>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#play" class="tsd-kind-icon">play</a></li>
- <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#resume" class="tsd-kind-icon">resume</a></li>
- <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="stream.html#stop" class="tsd-kind-icon">stop</a></li>
- <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>
- <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>
- </ul>
- </section>
- </div>
- </section>
- </section>
- <section class="tsd-panel-group tsd-member-group tsd-is-external">
- <h2>Properties</h2>
- <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
- <a name="audiomuted" class="tsd-anchor"></a>
- <h3>audio<wbr>Muted</h3>
- <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>
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>当前流是否 mute 了音频</p>
- </div>
- </div>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
- <a name="id" class="tsd-anchor"></a>
- <h3>id</h3>
- <div class="tsd-signature tsd-kind-icon">id<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>当前流ID</p>
- </div>
- </div>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
- <a name="mediastream" class="tsd-anchor"></a>
- <h3><span class="tsd-flag ts-flagReadonly">Readonly</span> media<wbr>Stream</h3>
- <div class="tsd-signature tsd-kind-icon">media<wbr>Stream<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">MediaStream</span></div>
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>当前流包含的媒体流,关于媒体流,请详见 <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream">MediaStream</a>。</p>
- </div>
- </div>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
- <a name="videomuted" class="tsd-anchor"></a>
- <h3>video<wbr>Muted</h3>
- <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>
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>当前流是否 mute 了视频</p>
- </div>
- </div>
- </section>
- </section>
- <section class="tsd-panel-group tsd-member-group tsd-is-external">
- <h2>Methods</h2>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="destroy" class="tsd-anchor"></a>
- <h3>destroy</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>销毁当前流,一般在本地流不再被使用时,可调用此方法销毁,解除摄像头或麦克风设备的占用。</p>
- <blockquote>
- <p>注:远端流,不需要手动调用此方法</p>
- </blockquote>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js">stream.destroy();</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="getaudiolevel" class="tsd-anchor"></a>
- <h3>get<wbr>Audio<wbr>Level</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>获取当前流的音量大小,只有当本地流或远端流中有音频数据才有效。</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-built_in">setInterval</span>(<span class="hljs-function">() =></span> {
- <span class="hljs-keyword">const</span> level = stream.getAudioLevel();
- <span class="hljs-keyword">if</span> (level > <span class="hljs-number">0</span>) {
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`user <span class="hljs-subst">${stream.userId}</span> is speaking`</span>);
- }
- }, <span class="hljs-number">200</span>);</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="getmediatype" class="tsd-anchor"></a>
- <h3>get<wbr>Media<wbr>Type</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>获取流的媒体类型</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> type = stream.getMediaType();</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <a href="../index.html#mediatype" class="tsd-signature-type">MediaType</a></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="getstats" class="tsd-anchor"></a>
- <h3>get<wbr>Stats</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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"><</span><a href="../interfaces/streamstats.html" class="tsd-signature-type">StreamStats</a><span class="tsd-signature-symbol">></span></li>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>获取流发布或订阅后的统计数据</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js">stream
- .getStats()
- .then(<span class="hljs-function">(<span class="hljs-params">stats</span>) =></span> {
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'当前流的统计数据为: '</span>, stats);
- });</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/streamstats.html" class="tsd-signature-type">StreamStats</a><span class="tsd-signature-symbol">></span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="hasaudio" class="tsd-anchor"></a>
- <h3>has<wbr>Audio</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>判断当前流是否有音频</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.hasAudio();</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="hasvideo" class="tsd-anchor"></a>
- <h3>has<wbr>Video</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>判断当前流是否有视频</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.hasVideo();</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="muteaudio" class="tsd-anchor"></a>
- <h3>mute<wbr>Audio</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>mute 当前流的音频</p>
- <ul>
- <li>本地流调用此方法时,将不向服务器推送音频数据,远端用户将收到 <code>mute-audio</code> 的事件通知</li>
- <li>远端流调用此方法时,仅为不从服务器拉取音频数据,并无事件通知远端用户</li>
- </ul>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.muteAudio();
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream'audio is muted <span class="hljs-subst">${stream.audioMuted}</span>`</span>);</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- <p>操作是否成功</p>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="mutevideo" class="tsd-anchor"></a>
- <h3>mute<wbr>Video</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>mute 当前流的视频</p>
- <ul>
- <li>本地流调用此方法时,将不向服务器推送视频数据,远端用户将收到 <code>mute-video</code> 的事件通知</li>
- <li>远端流调用此方法时,仅为不从服务器拉取视频数据,并无事件通知远端用户</li>
- </ul>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.muteVideo();
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream's video is muted <span class="hljs-subst">${stream.videoMuted}</span>`</span>);</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- <p>操作是否成功</p>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
- <a name="off" class="tsd-anchor"></a>
- <h3>off</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
- <li class="tsd-signature tsd-kind-icon">off<T><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"><</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">EventEmitter</span></li>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- <p>Inherited from EventEmitter.off</p>
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>取消监听流对象事件</p>
- </div>
- </div>
- <h4 class="tsd-type-parameters-title">Type parameters</h4>
- <ul class="tsd-type-parameters">
- <li>
- <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>
- </li>
- </ul>
- <h4 class="tsd-parameters-title">Parameters</h4>
- <ul class="tsd-parameters">
- <li>
- <h5>type: <span class="tsd-signature-type">T</span></h5>
- <div class="tsd-comment tsd-typography">
- <p>流对象事件类型,特别的,当为 '*' 时,取消监听所有事件</p>
- </div>
- </li>
- <li>
- <h5>listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">></span></h5>
- <div class="tsd-comment tsd-typography">
- <p>流对象事件监听函数</p>
- </div>
- </li>
- </ul>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
- <a name="on" class="tsd-anchor"></a>
- <h3>on</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited tsd-is-external">
- <li class="tsd-signature tsd-kind-icon">on<T><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"><</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">EventEmitter</span></li>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- <p>Inherited from EventEmitter.on</p>
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>监听流对象事件</p>
- </div>
- </div>
- <h4 class="tsd-type-parameters-title">Type parameters</h4>
- <ul class="tsd-type-parameters">
- <li>
- <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a></h4>
- </li>
- </ul>
- <h4 class="tsd-parameters-title">Parameters</h4>
- <ul class="tsd-parameters">
- <li>
- <h5>type: <span class="tsd-signature-type">T</span></h5>
- <div class="tsd-comment tsd-typography">
- <p>流事件类型</p>
- </div>
- </li>
- <li>
- <h5>listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">></span></h5>
- <div class="tsd-comment tsd-typography">
- <p>流事件监听函数</p>
- </div>
- </li>
- </ul>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">EventEmitter</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="play" class="tsd-anchor"></a>
- <h3>play</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></li>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>播放当前流</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> container = <span class="hljs-string">'xxx'</span>; <span class="hljs-comment">// 比如 id 为 xxx 的 div 元素</span>
- stream
- .play(container)
- .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =></span> {
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`播放失败: <span class="hljs-subst">${err}</span>`</span>); <span class="hljs-comment">// 一般由于浏览器对自动播放的限制导致播放失败</span>
- });</code></pre>
- </dd>
- <dt>reject</dt>
- <dd><p><a href="rtcerror.html">RtcError</a></p>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-parameters-title">Parameters</h4>
- <ul class="tsd-parameters">
- <li>
- <h5>container: <span class="tsd-signature-type">HTMLElement</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></h5>
- <div class="tsd-comment tsd-typography">
- <p>播放音视频时,包裹 video 标签所用的容器元素或容器元素的 ID</p>
- </div>
- </li>
- <li>
- <h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <a href="../interfaces/playoptions.html" class="tsd-signature-type">PlayOptions</a></h5>
- <div class="tsd-comment tsd-typography">
- <p>其他播放参数,参见<a href="../interfaces/playoptions.html">PlayOptions</a></p>
- </div>
- </li>
- </ul>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="resume" class="tsd-anchor"></a>
- <h3>resume</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></li>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>恢复播放流,一般由于浏览器限制无法自动播放时,可提示用户手动触发该方法进行恢复播放</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js">stream
- .resume()
- .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =></span> {
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`恢复播放失败:<span class="hljs-subst">${err}</span>`</span>);
- });</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="stop" class="tsd-anchor"></a>
- <h3>stop</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>停止播放当前流</p>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js">stream.stop();</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="unmuteaudio" class="tsd-anchor"></a>
- <h3>unmute<wbr>Audio</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>unmute 当前流的音频</p>
- <ul>
- <li>本地流调用此方法时,将向服务器推送音频数据,远端用户将收到 <code>unmute-audio</code> 的事件通知</li>
- <li>远端流调用此方法时,会从服务器拉取音频数据,并无事件通知远端用户</li>
- </ul>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteAudio();
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream's audio is muted <span class="hljs-subst">${stream.audioMuted}</span>`</span>);</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- <p>操作是否成功</p>
- </li>
- </ul>
- </section>
- <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a name="unmutevideo" class="tsd-anchor"></a>
- <h3>unmute<wbr>Video</h3>
- <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <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>
- </ul>
- <ul class="tsd-descriptions">
- <li class="tsd-description">
- <aside class="tsd-sources">
- </aside>
- <div class="tsd-comment tsd-typography">
- <div class="lead">
- <p>unmute 当前流的视频</p>
- <ul>
- <li>本地流调用此方法时,将向服务器推送视频数据,远端用户将收到 <code>unmute-video</code> 的事件通知</li>
- <li>远端流调用此方法时,会从服务器拉取视频数据,并无事件通知远端用户</li>
- </ul>
- </div>
- <dl class="tsd-comment-tags">
- <dt>example</dt>
- <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> result = stream.unmuteVideo();
- <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`stream's video is muted <span class="hljs-subst">${stream.videoMuted}</span>`</span>);</code></pre>
- </dd>
- </dl>
- </div>
- <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
- <p>操作是否成功</p>
- </li>
- </ul>
- </section>
- </section>
- </div>
- <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
- <nav class="tsd-navigation primary">
- <ul>
- <li class="globals ">
- <a href="../index.html"><em>Globals</em></a>
- </li>
- </ul>
- </nav>
- <nav class="tsd-navigation secondary menu-sticky">
- <ul class="before-current">
- </ul>
- <ul class="current">
- <li class="current tsd-kind-class tsd-is-external">
- <a href="stream.html" class="tsd-kind-icon">Stream</a>
- <ul>
- <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>
- <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
- <a href="stream.html#id" class="tsd-kind-icon">id</a>
- </li>
- <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>
- <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>
- <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a href="stream.html#destroy" class="tsd-kind-icon">destroy</a>
- </li>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a href="stream.html#play" class="tsd-kind-icon">play</a>
- </li>
- <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a href="stream.html#resume" class="tsd-kind-icon">resume</a>
- </li>
- <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
- <a href="stream.html#stop" class="tsd-kind-icon">stop</a>
- </li>
- <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>
- <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>
- </ul>
- </li>
- </ul>
- <ul class="after-current">
- </ul>
- </nav>
- </div>
- </div>
- </div>
- <footer class="with-border-bottom">
- <div class="container">
- <h2>Legend</h2>
- <div class="tsd-legend-group">
- </div>
- </div>
- </footer>
- <div class="container tsd-generator">
- <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
- </div>
- <div class="overlay"></div>
- <script src="../assets/js/main.js"></script>
- </body>
- </html>
|