This topic describes how to use Real-Time Communication (RTC) SDK for web to ingest streams when no microphones are available.
- Enable the subscription-only mode for your browser. This way, you can skip the browser check.
aliWebrtc.isSupport({isReceiveOnly: true}).then((re)=>{ // The subscription-only mode is supported. }).catch(err => { // The subscription-only mode is not supported. }) - Query the audio track that you want to replace and call the
setExternalMediaTrackmethod to replace the audio track with an external audio source.// Query the media track. let mediaStream = video.captureStream(); // video indicates the type of the media track that you want to query. // Query audio tracks. let audiotracks = mediaStream && mediaStream.getAudioTracks() // Select the audio track that you want to replace. let audiotrack = (audiotracks && audiotracks.length) ? audiotracks[0] // Replace the audio track with an external audio source. aliWebrtc.setExternalMediaTrack(audiotrack, 0);Note- Before the replacement, make sure that you stop ingesting streams.
- Every time you stop ingesting streams, you must configure an external audio source again.
- Ingest streams. You do not need to ingest a stream for the audio track. RTC SDK for web identifies that a stream is ingested for the external audio source, so the browser check is skipped.
该文章对您有帮助吗?